Skip to content

Updating Prompts, RCA Stages, Making UI More Aligned To Figma#33

Open
shekhar316 wants to merge 2 commits intocausaai:poc-mar26from
shekhar316:new-ui
Open

Updating Prompts, RCA Stages, Making UI More Aligned To Figma#33
shekhar316 wants to merge 2 commits intocausaai:poc-mar26from
shekhar316:new-ui

Conversation

@shekhar316
Copy link
Copy Markdown
Member

@shekhar316 shekhar316 commented Mar 30, 2026

This PR updates prompts, and makes UI more aligned with Figma

Summary by Sourcery

Refine RCA analysis outputs and dashboard presentation for clearer, structured incident insights and faster UI feedback.

New Features:

  • Introduce structured severity, confidence, supporting evidence, observable symptoms, and affected services fields in RCA reports.
  • Allow storing and surfacing a partial RCA report immediately after RCA analysis, before validation completes.

Enhancements:

  • Update the RCA LLM prompt and parsers to emit and extract additional structured sections including severity, supporting evidence bullets, observable symptoms, affected services, key evidence, and supported logs.
  • Improve GC anomaly explanation extraction and logging for clearer diagnostics.
  • Adjust the analysis details UI to a side‑by‑side highlights vs. RCA layout and simplify the evidence tab by removing sub-tabs and presenting evidence and supported logs directly.
  • Update the dashboard table to prioritize displaying the high-level issue as the issue title.
  • Refine RCA CSS to support the new overview layout and styled evidence/symptom components.

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 a structured RCA overview and metadata pipeline end-to-end: the LLM prompt now produces severity, structured evidence, symptoms and affected services; the backend parses and persists these fields (including a partial pre-validation report) and the dashboard UI is updated to show an RCA overview side‑by‑side with highlights and evidence aligned with the new design.

Sequence diagram for RCA analysis with partial report storage

sequenceDiagram
    actor User
    participant Dashboard
    participant AnalysisTrackingService
    participant RcaOrchestrator
    participant RootCauseAnalyst
    participant RcaAssertionExtractor

    User->>Dashboard: Start RCA for pod
    Dashboard->>AnalysisTrackingService: createSession
    AnalysisTrackingService-->>Dashboard: RcaAnalysisSession

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

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

    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 -> partialJson -> partialRcaReport

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

    AnalysisTrackingService-->>Dashboard: updated session with partial report
    Dashboard-->>User: Show RCA overview immediately

    RcaOrchestrator->>RcaAssertionExtractor: extractAssertions(rcaSection, artifacts)
    RcaAssertionExtractor-->>RcaOrchestrator: finalAssertions, weightedScore, finalStatus

    RcaOrchestrator->>RcaOrchestrator: compute confidence, finalDecision
    RcaOrchestrator->>RcaOrchestrator: build finalReport map
    RcaOrchestrator->>AnalysisTrackingService: storeFinalReport(sessionId, finalRcaReport)
    AnalysisTrackingService-->>RcaOrchestrator: ack

    AnalysisTrackingService-->>Dashboard: session completed with final report
    Dashboard-->>User: Show validated RCA report with severity and confidence
Loading

Class diagram for updated RCA reporting and tracking model

classDiagram
    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
    }

    class RcaAnalysisSession {
        +String sessionId
        +RcaReport report
        +AnalysisStatus status
    }

    class AnalysisTrackingService {
        +boolean storeArtifacts(sessionId, artifacts)
        +boolean storePartialReport(sessionId, report)
        +boolean storeFinalReport(sessionId, report)
        +void updateStatus(sessionId, status, message)
        +Optional~RcaAnalysisSession~ findBySessionId(sessionId)
    }

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

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

    class RcaAssertionExtractor {
        <<interface>>
        +String extractAssertions(rootCauseSection, artifacts)
    }

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

    AnalysisTrackingService --> RcaAnalysisSession : manages
    RcaAnalysisSession --> RcaReport : has
    RcaOrchestrator --> AnalysisTrackingService : uses
    RcaOrchestrator --> RootCauseAnalyst : calls
    RcaOrchestrator --> RcaAssertionExtractor : calls
    RcaOrchestrator --> EvidenceMatcherAgent : may_call
    RcaOrchestrator --> RcaReport : builds
Loading

Flow diagram for parsing structured RCA output into report fields

flowchart TD
    A_rcaOutput["RCA output from RootCauseAnalyst"] --> B_extractTitle["extractRootCauseTitle(rcaOutput)"]
    A_rcaOutput --> C_extractIssue["extractRootCause(rcaOutput)"]
    A_rcaOutput --> D_extractEvidence["extractKeyEvidence(rcaOutput)"]
    A_rcaOutput --> E_extractSupportedLogs["extractSupportedLogs(rcaOutput)"]
    A_rcaOutput --> F_extractSeverity["extractSeverity(rcaOutput)"]
    A_rcaOutput --> G_extractSupportingEvidenceBullets["extractSupportingEvidenceBullets(rcaOutput)"]
    A_rcaOutput --> H_extractObservableSymptoms["extractObservableSymptoms(rcaOutput)"]
    A_rcaOutput --> I_extractAffectedServices["extractAffectedServices(rcaOutput)"]

    B_extractTitle --> J_buildPartialReport["Build partialReport map"]
    C_extractIssue --> J_buildPartialReport
    D_extractEvidence --> J_buildPartialReport
    E_extractSupportedLogs --> J_buildPartialReport
    F_extractSeverity --> J_buildPartialReport
    G_extractSupportingEvidenceBullets --> J_buildPartialReport
    H_extractObservableSymptoms --> J_buildPartialReport
    I_extractAffectedServices --> J_buildPartialReport

    J_buildPartialReport --> K_serialize["Serialize to JSON"]
    K_serialize --> L_deserialize["Deserialize to RcaReport"]
    L_deserialize --> M_storePartial["AnalysisTrackingService.storePartialReport"]
Loading

File-Level Changes

Change Details Files
Add new RCA overview side-by-side layout and evidence presentation aligned with Figma.
  • Introduce RCA overview grid with responsive two-column layout for main issue and supporting evidence.
  • Define styling for severity and confidence badges, affected service tags, blue/orange RCA boxes, highlights lists, symptoms and evidence items, and info boxes.
  • Refactor analysisDetails.html RCA section into a two-column Highlights (highLevelIssue) and Root Cause Analysis (issue + subLevelIssue) view.
  • Simplify evidence tab by removing sub-tabs and rendering evidence text plus supported logs as separate sections with copy-to-clipboard hooks.
src/main/resources/META-INF/resources/css/dashboard.css
src/main/resources/templates/analysisDetails.html
Parse structured RCA sections from LLM output and propagate them through the report and tracking pipeline.
  • After RCA analysis, extract key evidence, supported logs, severity, supporting evidence bullets, observable symptoms, and affected services from the analyst output using new regex-based helpers.
  • Build a partial RcaReport from the unvalidated RCA output and persist it via trackingService.storePartialReport so the UI can render RCA results before validation completes.
  • Reuse RCA-derived evidence and supportedLogs instead of recomputing them from validation matchedLogs, while still computing validation metrics and scores.
  • Extend the final report map to include severity, confidenceLevel (from final validation status), supportingEvidenceBullets, observableSymptoms, and affectedServices, then serialize into RcaReport JSON.
src/main/java/com/causa/rca/service/RcaOrchestrator.java
src/main/java/com/causa/rca/service/AnalysisTrackingService.java
src/main/java/com/causa/rca/model/RcaReport.java
Tighten and extend RCA-related extraction logic and prompts for structured output and GC explanations.
  • Broaden ROOT_CAUSE extraction regex to handle SUPPORTING_EVIDENCE and flexible underscore/space separators between tokens.
  • Add helper methods to extract supported logs, key evidence, severity, supporting evidence bullets, observable symptoms, affected services, and GC explanations from raw LLM responses, including defensive defaults and logging.
  • Update the root cause analyst prompt to require a strict, fully structured text format including SEVERITY, SUPPORTING_EVIDENCE bullets, OBSERVABLE_SYMPTOMS, and AFFECTED_SERVICES sections with concrete examples and rules.
  • Improve GC handling by extracting a human-readable GC explanation for subLevelIssue and logging it separately from the anomaly type.
src/main/java/com/causa/rca/service/RcaOrchestrator.java
src/main/java/com/causa/rca/ai/RootCauseAnalyst.java
Support partial RCA report storage and new structured fields on the tracking and model side.
  • Add storePartialReport to AnalysisTrackingService to update an existing session with an interim RcaReport and log the operation.
  • Extend RcaReport with severity, confidenceLevel, supportingEvidenceBullets, observableSymptoms, and affectedServices fields for structured RCA overview display.
src/main/java/com/causa/rca/service/AnalysisTrackingService.java
src/main/java/com/causa/rca/model/RcaReport.java
Refine evidence matching prompts and dashboard list behavior for anonymization and better titles.
  • Adjust EvidenceMatcherAgent and RcaAssertionExtractor prompt examples to use anonymized placeholder container-name instead of concrete names.
  • Change dashboard.js to prioritize highLevelIssue as the main issue title in the dashboard table fallback chain.
src/main/java/com/causa/rca/ai/EvidenceMatcherAgent.java
src/main/java/com/causa/rca/ai/RcaAssertionExtractor.java
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 left some high level feedback:

  • The RCA output parsing now happens in multiple separate regex-based methods (severity, supporting evidence, symptoms, services, etc.); consider centralizing this into a single parser or shared helper to keep the format assumptions in one place and make future prompt/output format changes easier to manage.
  • In extractSeverity, unknown or malformed SEVERITY values silently fall back to "Medium"; adding a warning log or explicit handling for unexpected values would make it easier to detect prompt/output drift or LLM formatting issues in production.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The RCA output parsing now happens in multiple separate regex-based methods (severity, supporting evidence, symptoms, services, etc.); consider centralizing this into a single parser or shared helper to keep the format assumptions in one place and make future prompt/output format changes easier to manage.
- In `extractSeverity`, unknown or malformed SEVERITY values silently fall back to "Medium"; adding a warning log or explicit handling for unexpected values would make it easier to detect prompt/output drift or LLM formatting issues in production.

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.

@bharathappali bharathappali mentioned this pull request Mar 30, 2026
@shekhar316 shekhar316 marked this pull request as draft March 30, 2026 09:24
Signed-off-by: Shekhar Saxena <shekhar.saxena@ibm.com>
@shekhar316 shekhar316 marked this pull request as ready for review March 30, 2026 11:11
@shekhar316 shekhar316 changed the title Updating Prompts, Making UI More Aligned To Figma Updating Prompts, RCA Stages, Making UI More Aligned To Figma Mar 30, 2026
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 1 issue, and left some high level feedback:

  • In analysisDetails.html the Evidence tab headings seem swapped: the first section titled "Supported Logs" renders session.report.evidence, while the second section titled "Evidence" renders session.report.supportedLogs, which will be confusing for users; consider correcting the section titles to match their content.
  • The new RCA parsing helpers in RcaOrchestrator (extractSupportedLogs, extractKeyEvidence, extractSupportingEvidenceBullets, extractObservableSymptoms, extractAffectedServices, extractSeverity) share similar regex and line-splitting patterns; consider extracting a small parser/utility class to centralize this logic and make future prompt/format changes easier to manage.
  • Several of the new RCA overview CSS rules (e.g., hard-coded hex colors like #0f62fe, #ff832b, #e8f4fd) bypass the existing design tokens; consider replacing these with the existing CSS variables (or adding new tokens) to keep theming consistent and simplify future visual tweaks.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `analysisDetails.html` the Evidence tab headings seem swapped: the first section titled "Supported Logs" renders `session.report.evidence`, while the second section titled "Evidence" renders `session.report.supportedLogs`, which will be confusing for users; consider correcting the section titles to match their content.
- The new RCA parsing helpers in `RcaOrchestrator` (`extractSupportedLogs`, `extractKeyEvidence`, `extractSupportingEvidenceBullets`, `extractObservableSymptoms`, `extractAffectedServices`, `extractSeverity`) share similar regex and line-splitting patterns; consider extracting a small parser/utility class to centralize this logic and make future prompt/format changes easier to manage.
- Several of the new RCA overview CSS rules (e.g., hard-coded hex colors like `#0f62fe`, `#ff832b`, `#e8f4fd`) bypass the existing design tokens; consider replacing these with the existing CSS variables (or adding new tokens) to keep theming consistent and simplify future visual tweaks.

## Individual Comments

### Comment 1
<location path="src/main/java/com/causa/rca/service/RcaOrchestrator.java" line_range="528-532" />
<code_context>
     private String extractRootCause(String rcaOutput) {

         Pattern pattern = Pattern.compile(
-                "(?i)ROOT[_ ]CAUSE\\s*:\\s*(.*?)(?=KEY[_ ]EVIDENCE\\s*:|SUPPORTED[_ ]LOGS\\s*:|$)",
+                "(?i)ROOT[_\\s]CAUSE\\s*:\\s*(.*?)(?=SUPPORTING[_\\s]EVIDENCE\\s*:|KEY[_\\s]EVIDENCE\\s*:|SUPPORTED[_\\s]LOGS\\s*:|$)",
</code_context>
<issue_to_address>
**suggestion:** Line splitting assumes `\n` only, which can misbehave with `\r\n` or mixed line endings.

This affects the new extractors (`extractSupportedLogs`, `extractSupportingEvidenceBullets`, `extractObservableSymptoms`) that use `split("\n")`, which can leave stray `\r` characters and break bullet regex matching. Consider using `split("\\R")` or normalizing all `\r\n` to `\n` once up front to make the parsing resilient to mixed line endings.

Suggested implementation:

```java
split("\\R")

```

Based on your comment, you should verify and update all usages in:
1. `extractSupportedLogs(...)`
2. `extractSupportingEvidenceBullets(...)`
3. `extractObservableSymptoms(...)`

If any of these methods currently perform manual trimming of `\r` or similar workarounds, those can typically be removed once `split("\\R")` is in place, since the line terminators will no longer be part of the returned strings.
</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 528 to 532
Pattern pattern = Pattern.compile(
"(?i)ROOT[_ ]CAUSE\\s*:\\s*(.*?)(?=KEY[_ ]EVIDENCE\\s*:|SUPPORTED[_ ]LOGS\\s*:|$)",
"(?i)ROOT[_\\s]CAUSE\\s*:\\s*(.*?)(?=SUPPORTING[_\\s]EVIDENCE\\s*:|KEY[_\\s]EVIDENCE\\s*:|SUPPORTED[_\\s]LOGS\\s*:|$)",
Pattern.DOTALL);

Matcher matcher = pattern.matcher(rcaOutput);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Line splitting assumes \n only, which can misbehave with \r\n or mixed line endings.

This affects the new extractors (extractSupportedLogs, extractSupportingEvidenceBullets, extractObservableSymptoms) that use split("\n"), which can leave stray \r characters and break bullet regex matching. Consider using split("\\R") or normalizing all \r\n to \n once up front to make the parsing resilient to mixed line endings.

Suggested implementation:

split("\\R")

Based on your comment, you should verify and update all usages in:

  1. extractSupportedLogs(...)
  2. extractSupportingEvidenceBullets(...)
  3. extractObservableSymptoms(...)

If any of these methods currently perform manual trimming of \r or similar workarounds, those can typically be removed once split("\\R") is in place, since the line terminators will no longer be part of the returned strings.

@shekhar316
Copy link
Copy Markdown
Member Author

@dinogun could we please review this and merge it into the poc-mar26 branch? Thanks.

@shekhar316 shekhar316 self-assigned this Apr 13, 2026
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.

1 participant