Skip to content

feat(insights): wrap the guardrail recommendations API in GraphQL - #5837

Open
alonkeyval wants to merge 1 commit into
odigos-io:mainfrom
alonkeyval:feat/insights-recommendations-gql
Open

alonkeyval wants to merge 1 commit into
odigos-io:mainfrom
alonkeyval:feat/insights-recommendations-gql

Conversation

@alonkeyval

Copy link
Copy Markdown
Collaborator

What this PR does / why we need it:

Wraps the insights service's guardrail-recommendations API in GraphQL, so the UI
can list the attribute_correlation rules the engine mined from a transaction's
learning samples and apply one without the operator writing the spec by hand.

Queries insights.recommendations(...) / insights.recommendation(id), and
mutations apply / dismiss / restore / revert / preview / recompute.
Also adds the webapp GraphQL documents and registers the operations in the
ui-kit adapter.

Two wire quirks are absorbed here rather than pushed to the UI:

  • A partially failed bulk action answers 422 carrying both the items that
    succeeded and a reason per item that did not. Treating that as a request
    error would hide both halves, so the client decodes that body; every other
    non-2xx status is still an error.
  • live_since / live_last are time.Time with omitempty, which does
    nothing for a struct, so a recommendation live traffic has not reached yet
    carries Go's zero time. That maps to null instead of rendering as year 1.

why_it_matters is exposed but the engine never populates it — the security
narrative is generated into spec.why — noted in the schema description.

Needs an insights build with the recommendations API (v1.38.0-pre1+);
resolvers behave like every other insights field when it is unavailable.
UI side: odigos-io/ui-kit#1320.

Changelog entry: Does this PR introduce a user-facing bug fix, feature, dependency update, or breaking change??

NONE

🤖 Generated with Claude Code

The insights engine mines promoted transactions' relation samples for attribute
pairs that always agree and offers each as a ready-made attribute_correlation
rule. This exposes those eight REST endpoints to the UI, so an operator can
review a mined rule and apply it without writing the correlation spec by hand.

Queries: insights.recommendations(...) and insights.recommendation(id).
Mutations: apply / dismiss / restore / revert / preview / recompute.

Two wire quirks are handled here rather than pushed to the UI:

- A partially failed bulk action answers 422 carrying both the items that
  succeeded and a reason per item that did not. Treating that as a request
  error would hide both halves, so the client decodes the body instead;
  every other non-2xx status is still an error.
- live_since / live_last are time.Time with omitempty, which does nothing
  for a struct, so a recommendation that live traffic has not reached yet
  carries Go's zero time. That maps to null rather than rendering as year 1.

why_it_matters is exposed but the engine never populates it - the security
narrative is generated into spec.why instead; noted in the schema description.

Also adds the webapp GraphQL documents and registers the operations in the
ui-kit adapter.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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