[Obs AI Assistant] Anonymization support#223351
Conversation
…e, remove hash in function arguments
There was a problem hiding this comment.
Pull Request Overview
Adds end-to-end anonymization support—including redaction, deanonymization, new types, UI settings, and chat‐level highlighting—to the Observability AI Assistant plugin.
- Introduces hash‐based redaction/unredaction utilities and service methods
- Defines new types (DetectedEntity, Unredaction, AnonymizationRule) and runtime schema updates
- Adds UI settings for anonymization rules and integrates entity highlighting in chat components
Reviewed Changes
Copilot reviewed 32 out of 32 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| server/service/anonymization/deanonymize_text.ts | New service to replace hashes with original values |
| server/service/anonymization/chunk_text.ts | Utility to split text into inference‐sized chunks |
| server/routes/runtime_types.ts | Added unredactions runtime type to message schema |
| public/plugin.tsx | Refactored config retrieval for scopeFromConfig |
| public/index.ts | Export anonymization utilities and new settings key |
| public/components/message_panel/message_text.tsx | Render highlighted/anonymized content when provided |
| common/utils/anonymization/redaction.ts | Core redaction and unhashing functions |
| common/types.ts | New interfaces for DetectedEntity, Unredaction, etc. |
| common/ui_settings/settings_keys.ts | Added key for anonymization rules |
| common/index.ts | Exported AnonymizationRule and settings key |
| private/.../server/plugin.ts | Excluded anonymization rules from core settings reg. |
| private/.../config.ts | Formatted exposeToBrowser object |
| private/.../settings_page.test.tsx | Reformatted test config object |
| private/.../common/ui_settings.ts | Defined UI setting for anonymization rules |
| packages/shared/kbn-ai-assistant/src/utils/builders.ts | Added unredactions to builder types |
| packages/shared/kbn-ai-assistant/src/chat/chat_timeline.tsx | Integrated UI logic for anonymization highlighting |
| packages/shared/kbn-ai-assistant/src/chat/chat_item_content_inline_prompt_editor.tsx | Passed anonymized content into MessageText |
| packages/shared/kbn-ai-assistant/src/chat/chat_item.tsx | Added text extraction from ReactNode for clipboard |
| packages/shared/ai-infra/inference-common/src/chat_complete/events.ts | Defined ChatCompletionUnredactedMessageEvent |
Comments suppressed due to low confidence (3)
server/service/anonymization/deanonymize_text.ts:14
- The doc comment mentions placeholders with braces (e.g., "{hash123}"), but
HASH_REGEXonly matches raw 40-char hex strings. Update the doc or regex to stay consistent.
* Takes text containing hash placeholders like "{hash123}" and replaces
server/routes/runtime_types.ts:56
unredactionsis marked as required, but it should be optional to match theMessageinterface. Consider wrapping it int.partialor usingt.union([t.array(unredactionRt), t.undefined]).
unredactions: t.array(unredactionRt),
packages/shared/ai-infra/inference-common/src/chat_complete/events.ts:38
- The
unredactionspayload here includes onlyentity,class_name, andhash, but client highlighting relies on positional data (start_pos,end_pos). Consider adding those fields for consistency.
export interface ChatCompletionUnredactedMessageEvent<
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Public APIs missing exports
Page load bundle
History |
|
Starting backport for target branches: 8.19 https://github.com/elastic/kibana/actions/runs/15580615122 |
💔 All backports failed
Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
Re-submit of elastic#216352 as it has merge conflicts and we don't have write permissions for Sandra's remote. To test, add the following to your kibana.yml: ``` uiSettings: overrides: "observability:aiAssistantAnonymizationRules": - id: "ner" type: "ner" enabled: true - id: "beach" type: "regex" enabled: true pattern: "sandy" ``` --------- Co-authored-by: Sandra Gonzales <sandra.gonzales@elastic.co> Co-authored-by: Sandra G <neptunian@users.noreply.github.com>
|
Friendly reminder: Looks like this PR hasn’t been backported yet. |
Re-submit of elastic#216352 as it has merge conflicts and we don't have write permissions for Sandra's remote. To test, add the following to your kibana.yml: ``` uiSettings: overrides: "observability:aiAssistantAnonymizationRules": - id: "ner" type: "ner" enabled: true - id: "beach" type: "regex" enabled: true pattern: "sandy" ``` --------- Co-authored-by: Sandra Gonzales <sandra.gonzales@elastic.co> Co-authored-by: Sandra G <neptunian@users.noreply.github.com>
|
Friendly reminder: Looks like this PR hasn’t been backported yet. |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
Re-submit of elastic#216352 as it has merge conflicts and we don't have write permissions for Sandra's remote. To test, add the following to your kibana.yml: ``` uiSettings: overrides: "observability:aiAssistantAnonymizationRules": - id: "ner" type: "ner" enabled: true - id: "beach" type: "regex" enabled: true pattern: "sandy" ``` --------- Co-authored-by: Sandra Gonzales <sandra.gonzales@elastic.co> Co-authored-by: Sandra G <neptunian@users.noreply.github.com> (cherry picked from commit 71ec37a) # Conflicts: # x-pack/platform/packages/shared/kbn-ai-assistant/src/chat/chat_timeline.tsx # x-pack/platform/plugins/shared/observability_ai_assistant/server/service/client/index.ts
# Backport This will backport the following commits from `main` to `8.19`: - [[Obs AI Assistant] Anonymization support (#223351)](#223351) <!--- Backport version: 10.0.1 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Dario Gieselaar","email":"dario.gieselaar@elastic.co"},"sourceCommit":{"committedDate":"2025-06-11T09:00:40Z","message":"[Obs AI Assistant] Anonymization support (#223351)\n\nRe-submit of #216352 as it has\nmerge conflicts and we don't have write permissions for Sandra's remote.\n\nTo test, add the following to your kibana.yml:\n\n```\nuiSettings:\n overrides:\n \"observability:aiAssistantAnonymizationRules\":\n - id: \"ner\"\n type: \"ner\"\n enabled: true\n - id: \"beach\"\n type: \"regex\"\n enabled: true\n pattern: \"sandy\"\n```\n\n---------\n\nCo-authored-by: Sandra Gonzales <sandra.gonzales@elastic.co>\nCo-authored-by: Sandra G <neptunian@users.noreply.github.com>","sha":"71ec37a2a688ca5b0791658e7cc7d0634e7139a9","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:enhancement","backport missing","Team:Obs AI Assistant","ci:project-deploy-observability","backport:version","v9.1.0","v8.19.0"],"title":"[Obs AI Assistant] Anonymization support","number":223351,"url":"https://github.com/elastic/kibana/pull/223351","mergeCommit":{"message":"[Obs AI Assistant] Anonymization support (#223351)\n\nRe-submit of #216352 as it has\nmerge conflicts and we don't have write permissions for Sandra's remote.\n\nTo test, add the following to your kibana.yml:\n\n```\nuiSettings:\n overrides:\n \"observability:aiAssistantAnonymizationRules\":\n - id: \"ner\"\n type: \"ner\"\n enabled: true\n - id: \"beach\"\n type: \"regex\"\n enabled: true\n pattern: \"sandy\"\n```\n\n---------\n\nCo-authored-by: Sandra Gonzales <sandra.gonzales@elastic.co>\nCo-authored-by: Sandra G <neptunian@users.noreply.github.com>","sha":"71ec37a2a688ca5b0791658e7cc7d0634e7139a9"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/223351","number":223351,"mergeCommit":{"message":"[Obs AI Assistant] Anonymization support (#223351)\n\nRe-submit of #216352 as it has\nmerge conflicts and we don't have write permissions for Sandra's remote.\n\nTo test, add the following to your kibana.yml:\n\n```\nuiSettings:\n overrides:\n \"observability:aiAssistantAnonymizationRules\":\n - id: \"ner\"\n type: \"ner\"\n enabled: true\n - id: \"beach\"\n type: \"regex\"\n enabled: true\n pattern: \"sandy\"\n```\n\n---------\n\nCo-authored-by: Sandra Gonzales <sandra.gonzales@elastic.co>\nCo-authored-by: Sandra G <neptunian@users.noreply.github.com>","sha":"71ec37a2a688ca5b0791658e7cc7d0634e7139a9"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> --------- Co-authored-by: Dario Gieselaar <dario.gieselaar@elastic.co> Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Re-submit of #216352 as it has merge conflicts and we don't have write permissions for Sandra's remote.
To test, add the following to your kibana.yml: