[SigEvents] Add description to KI (Knowledge Indicators) queries#257457
[SigEvents] Add description to KI (Knowledge Indicators) queries#257457tonyghiani merged 22 commits intoelastic:mainfrom
Conversation
|
Pinging @elastic/actionable-obs-team (Team:actionable-obs) |
…:tonyghiani/kibana into feat/add-description-to-query-generation
ruflin
left a comment
There was a problem hiding this comment.
Did a manual test and works as expected.
📝 WalkthroughWalkthroughThe PR adds a Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Warning Tools execution failed with the following error: Failed to run tools: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error) Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
x-pack/platform/plugins/shared/streams/server/lib/streams/assets/query/query_service.ts (1)
112-115: Harden description migration to normalize invalid values, not only missing keys.Using
inalone skips cases wherequery.descriptionexists but isnull/non-string.Suggested hardening
- if (!(QUERY_DESCRIPTION in migrated)) { + if (typeof migrated[QUERY_DESCRIPTION] !== 'string') { migrated = { ...migrated, [QUERY_DESCRIPTION]: '' }; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@x-pack/platform/plugins/shared/streams/server/lib/streams/assets/query/query_service.ts` around lines 112 - 115, The migration should normalize invalid description values, not only add missing keys: replace the current check using "in" with a guard that sets migrated[QUERY_DESCRIPTION] to '' whenever its type is not a string (covers undefined, null, and non-string values); update the code around the migrated object (the block referencing QUERY_DESCRIPTION and the local variable migrated) to coerce any non-string description to an empty string.x-pack/platform/plugins/shared/streams/server/routes/queries/route.ts (1)
101-103: Defaultdescriptionduring upsert writes to keep stored shape consistent.If omitted by older callers, this currently persists sparse docs and defers normalization to migration.
Suggested write-side default
- description: body.description, + description: body.description ?? '',🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@x-pack/platform/plugins/shared/streams/server/routes/queries/route.ts` around lines 101 - 103, Upsert handler in route.ts is persisting documents without a description when body.description is omitted; change the write to default description to an empty string so stored docs keep a consistent shape by writing description: body.description ?? '' alongside title and esql (locate the upsert/create handler that constructs the object with title, description, esql using the body variable).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@x-pack/platform/plugins/shared/streams/server/lib/streams/assets/query/query_service.ts`:
- Around line 112-115: The migration should normalize invalid description
values, not only add missing keys: replace the current check using "in" with a
guard that sets migrated[QUERY_DESCRIPTION] to '' whenever its type is not a
string (covers undefined, null, and non-string values); update the code around
the migrated object (the block referencing QUERY_DESCRIPTION and the local
variable migrated) to coerce any non-string description to an empty string.
In `@x-pack/platform/plugins/shared/streams/server/routes/queries/route.ts`:
- Around line 101-103: Upsert handler in route.ts is persisting documents
without a description when body.description is omitted; change the write to
default description to an empty string so stored docs keep a consistent shape by
writing description: body.description ?? '' alongside title and esql (locate the
upsert/create handler that constructs the object with title, description, esql
using the body variable).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 78261a9c-225b-49a1-b5bb-3d8b6d3a3231
📒 Files selected for processing (21)
oas_docs/output/kibana.serverless.yamloas_docs/output/kibana.yamlx-pack/platform/packages/shared/kbn-streams-ai/src/significant_events/generate_significant_events.tsx-pack/platform/packages/shared/kbn-streams-ai/src/significant_events/prompt.tsx-pack/platform/packages/shared/kbn-streams-ai/src/significant_events/system_prompt.textx-pack/platform/packages/shared/kbn-streams-ai/src/significant_events/task_description.textx-pack/platform/packages/shared/kbn-streams-schema/src/api/significant_events/index.tsx-pack/platform/packages/shared/kbn-streams-schema/src/queries/index.tsx-pack/platform/plugins/shared/streams/server/lib/significant_events/generate_significant_events.tsx-pack/platform/plugins/shared/streams/server/lib/streams/assets/fields.tsx-pack/platform/plugins/shared/streams/server/lib/streams/assets/query/query_client.tsx-pack/platform/plugins/shared/streams/server/lib/streams/assets/query/query_service.tsx-pack/platform/plugins/shared/streams/server/lib/streams/assets/storage_settings.tsx-pack/platform/plugins/shared/streams/server/lib/tasks/task_definitions/onboarding.tsx-pack/platform/plugins/shared/streams/server/routes/queries/route.tsx-pack/platform/plugins/shared/streams_app/public/components/significant_events_discovery/components/queries_table/query_details_flyout.tsxx-pack/platform/plugins/shared/streams_app/public/components/stream_detail_significant_events_view/add_significant_event_flyout/add_significant_event_flyout.tsxx-pack/platform/plugins/shared/streams_app/public/components/stream_detail_significant_events_view/add_significant_event_flyout/generated_flow_form/generated_event_preview.tsxx-pack/platform/plugins/shared/streams_app/public/components/stream_detail_significant_events_view/add_significant_event_flyout/manual_flow_form/manual_flow_form.tsxx-pack/platform/test/api_integration_deployment_agnostic/apis/streams/queries.tsx-pack/platform/test/api_integration_deployment_agnostic/apis/streams/significant_events.ts
x-pack/platform/packages/shared/kbn-streams-ai/src/significant_events/prompt.ts
Show resolved
Hide resolved
x-pack/platform/packages/shared/kbn-streams-schema/src/queries/index.ts
Outdated
Show resolved
Hide resolved
...ic/components/significant_events_discovery/components/queries_table/query_details_flyout.tsx
Outdated
Show resolved
Hide resolved
⏳ Build in-progress, with failures
Failed CI StepsHistory
|
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Public APIs missing comments
Async chunks
History
|
…7457) ## 📓 Summary This PR adds a `description` field to significant event queries so that each query carries a natural-language explanation of what it detects and why it matters. The LLM now generates descriptions alongside queries during the AI generation flow, and users can view and edit descriptions through the manual creation form, the generated event preview, and the discovery query details flyout. Existing queries without a description are migrated on read via the storage adapter's `migrateSource` callback, which back-fills an empty string. ## 🧪 Testing - Create a significant event manually via the stream detail flyout and verify the description field appears, can be filled in, and is persisted after save. - Trigger AI generation and confirm generated queries include descriptions visible in the expanded preview; edit a description and verify the change is saved. - Open an existing query (created before this change) in the discovery details flyout and confirm it shows an empty description placeholder without errors; edit and save a description from there. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes * **New Features** * Added description field to queries throughout the system, allowing users to provide contextual information about what each query detects and why it matters. * Enabled editing and viewing of query descriptions in UI components including forms, flyouts, and detail panels. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Nicolas Ruflin <ruflin@elastic.co>
…stic#257457) ## 📓 Summary This PR adds a `description` field to significant event queries so that each query carries a natural-language explanation of what it detects and why it matters. The LLM now generates descriptions alongside queries during the AI generation flow, and users can view and edit descriptions through the manual creation form, the generated event preview, and the discovery query details flyout. Existing queries without a description are migrated on read via the storage adapter's `migrateSource` callback, which back-fills an empty string. ## 🧪 Testing - Create a significant event manually via the stream detail flyout and verify the description field appears, can be filled in, and is persisted after save. - Trigger AI generation and confirm generated queries include descriptions visible in the expanded preview; edit a description and verify the change is saved. - Open an existing query (created before this change) in the discovery details flyout and confirm it shows an empty description placeholder without errors; edit and save a description from there. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Release Notes * **New Features** * Added description field to queries throughout the system, allowing users to provide contextual information about what each query detects and why it matters. * Enabled editing and viewing of query descriptions in UI components including forms, flyouts, and detail panels. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Nicolas Ruflin <ruflin@elastic.co>
📓 Summary
This PR adds a
descriptionfield to significant event queries so that each query carries a natural-language explanation of what it detects and why it matters. The LLM now generates descriptions alongside queries during the AI generation flow, and users can view and edit descriptions through the manual creation form, the generated event preview, and the discovery query details flyout.Existing queries without a description are migrated on read via the storage adapter's
migrateSourcecallback, which back-fills an empty string.🧪 Testing
Summary by CodeRabbit
Release Notes