feat(hcpctl): add taxonomy classification to snapshot analyze - #6504
feat(hcpctl): add taxonomy classification to snapshot analyze#6504Giulio Frasca (gmfrasca) wants to merge 6 commits into
Conversation
Define L1/L2 taxonomy constants, Classification struct, and add classification field to DraftChain and HydratedChain for ARO-28427. Signed-off-by: Giulio Frasca <gfrasca@redhat.com>
…ompt Add L1/L2 category definitions, confidence scoring guidance, and classification field to the output JSON schema example in system.md. Signed-off-by: Giulio Frasca <gfrasca@redhat.com>
…line Validate L1/L2 category values, L2 presence rules, and confidence range in ValidateDraft() with correction feedback for the LLM. Signed-off-by: Giulio Frasca <gfrasca@redhat.com>
Show L1 category, L2 component, and confidence percentage between the Root Cause and Summary sections in RenderMarkdown(). Signed-off-by: Giulio Frasca <gfrasca@redhat.com>
Add L1/L2 classification sections to all four exemplar analyses for few-shot learning of the taxonomy format. Signed-off-by: Giulio Frasca <gfrasca@redhat.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: gmfrasca The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Skipping CI for Draft Pull Request. |
There was a problem hiding this comment.
Pull request overview
Adds an LLM-provided failure taxonomy classification to hcpctl snapshot analyze analysis artifacts so downstream systems can aggregate and triage failures by category/component with an associated confidence score.
Changes:
- Introduces a
classificationobject (L1 category, optional L2 subcategory, confidence) to the analysis JSON schema and hydrates it through to markdown rendering. - Adds validation rules enforcing allowed L1/L2 values and confidence bounds, and updates the agent system prompt to require the classification output.
- Adds unit tests for parsing/validation/rendering behavior around classification.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tooling/hcpctl/pkg/agent/validation.go | Validates presence and correctness of classification (L1/L2/confidence). |
| tooling/hcpctl/pkg/agent/schema.go | Adds taxonomy constants and Classification struct; wires into Draft/Hydrated chain schemas. |
| tooling/hcpctl/pkg/agent/render.go | Renders a “Classification” markdown section including confidence percentage. |
| tooling/hcpctl/pkg/agent/prompts/system.md | Updates the agent contract to require classification and defines taxonomy rules. |
| tooling/hcpctl/pkg/agent/prompts/exemplars/clusters-service-worker-race-condition.md | Adds a Classification section to an exemplar. |
| tooling/hcpctl/pkg/agent/prompts/exemplars/cluster-installation-ignition-failure.md | Adds a Classification section to an exemplar. |
| tooling/hcpctl/pkg/agent/prompts/exemplars/cluster-installation-azure-disk-failure.md | Adds a Classification section to an exemplar. |
| tooling/hcpctl/pkg/agent/prompts/exemplars/cluster-creation-timeout-z-stream-upgrade.md | Adds a Classification section to an exemplar. |
| tooling/hcpctl/pkg/agent/hydration.go | Carries classification from draft into hydrated output. |
| tooling/hcpctl/pkg/agent/classification_test.go | Adds unit tests for classification parsing, validation, and rendering. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| - **Category:** Product Failures | ||
| - **Component:** Cluster Service | ||
|
|
There was a problem hiding this comment.
Intentional - confidence is omitted from exemplars so the LLM infers it from the evidence rather than mimicking a hardcoded value. The system prompt and JSON schema example already demonstrate the confidence field; the exemplars teach format and category assignment, not specific confidence values.
Cover schema parsing, validation rules, and markdown rendering for the new Classification struct. Signed-off-by: Giulio Frasca <gfrasca@redhat.com>
0a3db92 to
af0ab1f
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.
Suppressed comments (2)
tooling/hcpctl/pkg/agent/validation.go:149
- The confidence validation can’t distinguish between an explicitly provided 0.0 and a missing
confidencefield (JSON unmarshalling defaults float64 to 0). If the agent omitsconfidence, this check will pass and downstream consumers will treat it as 0% confidence, contradicting the prompt requirement that confidence is always present.
if draft.Classification.Confidence < 0 || draft.Classification.Confidence > 1 {
tooling/hcpctl/pkg/agent/classification_test.go:212
- In the "valid" test cases, this only asserts there are no classification problems; other validation problems would still allow these cases to pass and could mask regressions in non-classification draft validation.
if tt.wantCategory == "" {
if len(problems) > 0 {
t.Errorf("expected no classification problems, got %d: %v", len(problems), problems)
}
return
}
|
/retest |
ARO-28427
What
Adds taxonomy classification to
hcpctl snapshot analyzeoutput. Each analysis now includes an L1 category, optional L2 subcategory (for Product Failures), and a confidence score assigned by the LLM.Why
Automated classification enables downstream aggregation and triage of test failures by category (Azure Problems, Deployment Failures, Product Failures, Test Reliability) without manual review of each analysis.
Testing
Unit tests (
classification_test.go): schema parsing (with/without classification), validation (14 subtests covering all L1/L2/confidence rules and boundary values), and markdown rendering (with L2, without L2, without classification).Manual verification with
hcpctl snapshot analyze:analysis.jsoncontains aclassificationobject withl1_category,confidence, andl2_subcategory(when applicable)analysis.mdcontains a "Classification" section with Category, Component (if Product Failures), and Confidence percentagePR Checklist