Skip to content

[Security GenAI] Use stable IDs for Security AI Prompt saved object filenames#265301

Merged
KDKHD merged 5 commits intoelastic:mainfrom
KDKHD:feature/237178-stable-prompt-filenames
Apr 27, 2026
Merged

[Security GenAI] Use stable IDs for Security AI Prompt saved object filenames#265301
KDKHD merged 5 commits intoelastic:mainfrom
KDKHD:feature/237178-stable-prompt-filenames

Conversation

@KDKHD
Copy link
Copy Markdown
Member

@KDKHD KDKHD commented Apr 23, 2026

Summary

Resolves #237178.

The generate_security_ai_prompts_script.ts script previously generated saved object filenames using a random UUID on every invocation (e.g. security_ai_prompts-022f0559-929f-4b06-ad08-571fc9b768ca.json). This made PR reviews noisy and required a rm ./*.json step when copying files into the integration package.

This PR replaces uuidv4() with a deterministic generateStableId function that builds the ID from promptGroupId, promptId, and optionally provider and model — all lowercased. Example stable filename:

security_ai_prompts-aiassistant-systemprompt-openai.json

Changes

  • Script: replaced uuidv4() with generateStableId(prompt) that derives a stable, lowercase ID from the prompt's identifying fields. Removed uuid import.
  • Tests: added 13 Jest unit tests for generateStableId, generateSavedObject, and generateSavedObjects.
  • README: removed the rm ./*.json step from the developer update flow — with stable filenames, cp overwrites files in place without needing to clear them first.

Migration note

The first time the script runs after this change, the integration repo (elastic/integrations) will still contain the old UUID-named files. A one-time rm ./*.json followed by cp in that repo is needed to fully replace them with stable-named files. After that, the rm step is no longer required.

Test plan

  • node scripts/jest x-pack/solutions/security/plugins/elastic_assistant/scripts/generate_security_ai_prompts_script.test.ts — 13 tests pass
  • node scripts/check_changes.ts — lint and pre-commit checks pass
  • Run yarn generate-security-ai-prompts in x-pack/solutions/security/plugins/elastic_assistant and confirm output filenames are stable across multiple invocations

…ilenames (elastic#237178)

Generate saved object filenames from promptGroupId, promptId, provider,
and model instead of a random UUID, so filenames are stable across script
invocations. Removes the need for `rm ./*.json` in the integration update
workflow and makes PR diffs easier to review.
@KDKHD KDKHD requested a review from a team as a code owner April 23, 2026 13:34
@KDKHD KDKHD added backport:skip This PR does not require backporting release_note:skip Skip the PR/issue when compiling release notes labels Apr 23, 2026
@KDKHD
Copy link
Copy Markdown
Member Author

KDKHD commented Apr 23, 2026

/ci

`naturalLanguageESQLTool` → `natural-language-esql-tool`, rather than
collapsing everything to `naturallanguageesqltool`.
@KDKHD
Copy link
Copy Markdown
Member Author

KDKHD commented Apr 23, 2026

Files look like this now:

Wrote saved object to file: "../../../../../target/security_ai_prompts/security_ai_prompts-attack-discovery-generation-insights.json"
Wrote saved object to file: "../../../../../target/security_ai_prompts/security_ai_prompts-ai-assistant-chat-title.json"
Wrote saved object to file: "../../../../../target/security_ai_prompts/security_ai_prompts-ai-assistant-chat-title-bedrock.json"
Wrote saved object to file: "../../../../../target/security_ai_prompts/security_ai_prompts-ai-assistant-chat-title-gemini.json"
Wrote saved object to file: "../../../../../target/security_ai_prompts/security_ai_prompts-defend-insights-incompatible-antivirus-defend-insights-incompatible-antivirus-default.json"
Wrote saved object to file: "../../../../../target/security_ai_prompts/security_ai_prompts-defend-insights-incompatible-antivirus-defend-insights-incompatible-antivirus-refine.json"
Wrote saved object to file: "../../../../../target/security_ai_prompts/security_ai_prompts-defend-insights-incompatible-antivirus-defend-insights-incompatible-antivirus-continue.json"
Wrote saved object to file: "../../../../../target/security_ai_prompts/security_ai_prompts-defend-insights-incompatible-antivirus-defend-insights-incompatible-antivirus-group.json"
Wrote saved object to file: "../../../../../target/security_ai_prompts/security_ai_prompts-defend-insights-incompatible-antivirus-defend-insights-incompatible-antivirus-events.json"

KDKHD and others added 2 commits April 23, 2026 15:42
model-only and provider-only with the same value (e.g. 'openai') would
produce identical IDs. Gate model on provider being present — a model
without a provider is not a meaningful prompt lookup key.
@KDKHD
Copy link
Copy Markdown
Member Author

KDKHD commented Apr 23, 2026

/ci

@KDKHD KDKHD enabled auto-merge (squash) April 24, 2026 08:11
@KDKHD KDKHD added backport:version Backport to applied version labels v8.19.0 v9.3.0 v9.4.0 v9.5.0 and removed backport:skip This PR does not require backporting labels Apr 24, 2026
Copy link
Copy Markdown
Contributor

@andrew-goldstein andrew-goldstein left a comment

Choose a reason for hiding this comment

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

Thanks @KDKHD, this is a huge improvement to devex and review process!
LGTM 🚀

@kibanamachine
Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

✅ unchanged

@KDKHD KDKHD merged commit 6f23495 into elastic:main Apr 27, 2026
18 checks passed
@kibanamachine
Copy link
Copy Markdown
Contributor

Starting backport for target branches: 8.19, 9.3, 9.4

https://github.com/elastic/kibana/actions/runs/25003837492

@kibanamachine
Copy link
Copy Markdown
Contributor

💚 All backports created successfully

Status Branch Result
8.19
9.3
9.4

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Apr 27, 2026
…ject filenames (#265301) (#265824)

# Backport

This will backport the following commits from `main` to `9.4`:
- [[Security GenAI] Use stable IDs for Security AI Prompt saved object
filenames (#265301)](#265301)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Kenneth
Kreindler","email":"42113355+KDKHD@users.noreply.github.com"},"sourceCommit":{"committedDate":"2026-04-27T15:23:37Z","message":"[Security
GenAI] Use stable IDs for Security AI Prompt saved object filenames
(#265301)\n\n## Summary\n\nResolves #237178.\n\nThe
`generate_security_ai_prompts_script.ts` script previously
generated\nsaved object filenames using a random UUID on every
invocation
(e.g.\n`security_ai_prompts-022f0559-929f-4b06-ad08-571fc9b768ca.json`).
This\nmade PR reviews noisy and required a `rm ./*.json` step when
copying\nfiles into the integration package.\n\nThis PR replaces
`uuidv4()` with a deterministic `generateStableId`\nfunction that builds
the ID from `promptGroupId`, `promptId`, and\noptionally `provider` and
`model` — all lowercased. Example
stable\nfilename:\n\n```\nsecurity_ai_prompts-aiassistant-systemprompt-openai.json\n```\n\n###
Changes\n\n- **Script**: replaced `uuidv4()` with
`generateStableId(prompt)` that\nderives a stable, lowercase ID from the
prompt's identifying fields.\nRemoved `uuid` import.\n- **Tests**: added
13 Jest unit tests for `generateStableId`,\n`generateSavedObject`, and
`generateSavedObjects`.\n- **README**: removed the `rm ./*.json` step
from the developer update\nflow — with stable filenames, `cp` overwrites
files in place without\nneeding to clear them first.\n\n### Migration
note\n\nThe first time the script runs after this change, the
integration repo\n(`elastic/integrations`) will still contain the old
UUID-named files. A\none-time `rm ./*.json` followed by `cp` in that
repo is needed to fully\nreplace them with stable-named files. After
that, the `rm` step is no\nlonger required.\n\n## Test plan\n\n- [x]
`node
scripts/jest\nx-pack/solutions/security/plugins/elastic_assistant/scripts/generate_security_ai_prompts_script.test.ts`\n—
13 tests pass\n- [x] `node scripts/check_changes.ts` — lint and
pre-commit checks pass\n- [x] Run `yarn generate-security-ai-prompts`
in\n`x-pack/solutions/security/plugins/elastic_assistant` and confirm
output\nfilenames are stable across multiple
invocations\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"6f23495f1b94f6a1fa1e5735ae00444164d770a4","branchLabelMapping":{"^v9.5.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:version","v8.19.0","v9.3.0","v9.4.0","v9.5.0"],"title":"[Security
GenAI] Use stable IDs for Security AI Prompt saved object
filenames","number":265301,"url":"https://github.com/elastic/kibana/pull/265301","mergeCommit":{"message":"[Security
GenAI] Use stable IDs for Security AI Prompt saved object filenames
(#265301)\n\n## Summary\n\nResolves #237178.\n\nThe
`generate_security_ai_prompts_script.ts` script previously
generated\nsaved object filenames using a random UUID on every
invocation
(e.g.\n`security_ai_prompts-022f0559-929f-4b06-ad08-571fc9b768ca.json`).
This\nmade PR reviews noisy and required a `rm ./*.json` step when
copying\nfiles into the integration package.\n\nThis PR replaces
`uuidv4()` with a deterministic `generateStableId`\nfunction that builds
the ID from `promptGroupId`, `promptId`, and\noptionally `provider` and
`model` — all lowercased. Example
stable\nfilename:\n\n```\nsecurity_ai_prompts-aiassistant-systemprompt-openai.json\n```\n\n###
Changes\n\n- **Script**: replaced `uuidv4()` with
`generateStableId(prompt)` that\nderives a stable, lowercase ID from the
prompt's identifying fields.\nRemoved `uuid` import.\n- **Tests**: added
13 Jest unit tests for `generateStableId`,\n`generateSavedObject`, and
`generateSavedObjects`.\n- **README**: removed the `rm ./*.json` step
from the developer update\nflow — with stable filenames, `cp` overwrites
files in place without\nneeding to clear them first.\n\n### Migration
note\n\nThe first time the script runs after this change, the
integration repo\n(`elastic/integrations`) will still contain the old
UUID-named files. A\none-time `rm ./*.json` followed by `cp` in that
repo is needed to fully\nreplace them with stable-named files. After
that, the `rm` step is no\nlonger required.\n\n## Test plan\n\n- [x]
`node
scripts/jest\nx-pack/solutions/security/plugins/elastic_assistant/scripts/generate_security_ai_prompts_script.test.ts`\n—
13 tests pass\n- [x] `node scripts/check_changes.ts` — lint and
pre-commit checks pass\n- [x] Run `yarn generate-security-ai-prompts`
in\n`x-pack/solutions/security/plugins/elastic_assistant` and confirm
output\nfilenames are stable across multiple
invocations\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"6f23495f1b94f6a1fa1e5735ae00444164d770a4"}},"sourceBranch":"main","suggestedTargetBranches":["8.19","9.3","9.4"],"targetPullRequestStates":[{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.3","label":"v9.3.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.4","label":"v9.4.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.5.0","branchLabelMappingKey":"^v9.5.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/265301","number":265301,"mergeCommit":{"message":"[Security
GenAI] Use stable IDs for Security AI Prompt saved object filenames
(#265301)\n\n## Summary\n\nResolves #237178.\n\nThe
`generate_security_ai_prompts_script.ts` script previously
generated\nsaved object filenames using a random UUID on every
invocation
(e.g.\n`security_ai_prompts-022f0559-929f-4b06-ad08-571fc9b768ca.json`).
This\nmade PR reviews noisy and required a `rm ./*.json` step when
copying\nfiles into the integration package.\n\nThis PR replaces
`uuidv4()` with a deterministic `generateStableId`\nfunction that builds
the ID from `promptGroupId`, `promptId`, and\noptionally `provider` and
`model` — all lowercased. Example
stable\nfilename:\n\n```\nsecurity_ai_prompts-aiassistant-systemprompt-openai.json\n```\n\n###
Changes\n\n- **Script**: replaced `uuidv4()` with
`generateStableId(prompt)` that\nderives a stable, lowercase ID from the
prompt's identifying fields.\nRemoved `uuid` import.\n- **Tests**: added
13 Jest unit tests for `generateStableId`,\n`generateSavedObject`, and
`generateSavedObjects`.\n- **README**: removed the `rm ./*.json` step
from the developer update\nflow — with stable filenames, `cp` overwrites
files in place without\nneeding to clear them first.\n\n### Migration
note\n\nThe first time the script runs after this change, the
integration repo\n(`elastic/integrations`) will still contain the old
UUID-named files. A\none-time `rm ./*.json` followed by `cp` in that
repo is needed to fully\nreplace them with stable-named files. After
that, the `rm` step is no\nlonger required.\n\n## Test plan\n\n- [x]
`node
scripts/jest\nx-pack/solutions/security/plugins/elastic_assistant/scripts/generate_security_ai_prompts_script.test.ts`\n—
13 tests pass\n- [x] `node scripts/check_changes.ts` — lint and
pre-commit checks pass\n- [x] Run `yarn generate-security-ai-prompts`
in\n`x-pack/solutions/security/plugins/elastic_assistant` and confirm
output\nfilenames are stable across multiple
invocations\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"6f23495f1b94f6a1fa1e5735ae00444164d770a4"}}]}]
BACKPORT-->

Co-authored-by: Kenneth Kreindler <42113355+KDKHD@users.noreply.github.com>
kibanamachine added a commit that referenced this pull request Apr 27, 2026
…bject filenames (#265301) (#265822)

# Backport

This will backport the following commits from `main` to `8.19`:
- [[Security GenAI] Use stable IDs for Security AI Prompt saved object
filenames (#265301)](#265301)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Kenneth
Kreindler","email":"42113355+KDKHD@users.noreply.github.com"},"sourceCommit":{"committedDate":"2026-04-27T15:23:37Z","message":"[Security
GenAI] Use stable IDs for Security AI Prompt saved object filenames
(#265301)\n\n## Summary\n\nResolves #237178.\n\nThe
`generate_security_ai_prompts_script.ts` script previously
generated\nsaved object filenames using a random UUID on every
invocation
(e.g.\n`security_ai_prompts-022f0559-929f-4b06-ad08-571fc9b768ca.json`).
This\nmade PR reviews noisy and required a `rm ./*.json` step when
copying\nfiles into the integration package.\n\nThis PR replaces
`uuidv4()` with a deterministic `generateStableId`\nfunction that builds
the ID from `promptGroupId`, `promptId`, and\noptionally `provider` and
`model` — all lowercased. Example
stable\nfilename:\n\n```\nsecurity_ai_prompts-aiassistant-systemprompt-openai.json\n```\n\n###
Changes\n\n- **Script**: replaced `uuidv4()` with
`generateStableId(prompt)` that\nderives a stable, lowercase ID from the
prompt's identifying fields.\nRemoved `uuid` import.\n- **Tests**: added
13 Jest unit tests for `generateStableId`,\n`generateSavedObject`, and
`generateSavedObjects`.\n- **README**: removed the `rm ./*.json` step
from the developer update\nflow — with stable filenames, `cp` overwrites
files in place without\nneeding to clear them first.\n\n### Migration
note\n\nThe first time the script runs after this change, the
integration repo\n(`elastic/integrations`) will still contain the old
UUID-named files. A\none-time `rm ./*.json` followed by `cp` in that
repo is needed to fully\nreplace them with stable-named files. After
that, the `rm` step is no\nlonger required.\n\n## Test plan\n\n- [x]
`node
scripts/jest\nx-pack/solutions/security/plugins/elastic_assistant/scripts/generate_security_ai_prompts_script.test.ts`\n—
13 tests pass\n- [x] `node scripts/check_changes.ts` — lint and
pre-commit checks pass\n- [x] Run `yarn generate-security-ai-prompts`
in\n`x-pack/solutions/security/plugins/elastic_assistant` and confirm
output\nfilenames are stable across multiple
invocations\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"6f23495f1b94f6a1fa1e5735ae00444164d770a4","branchLabelMapping":{"^v9.5.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:version","v8.19.0","v9.3.0","v9.4.0","v9.5.0"],"title":"[Security
GenAI] Use stable IDs for Security AI Prompt saved object
filenames","number":265301,"url":"https://github.com/elastic/kibana/pull/265301","mergeCommit":{"message":"[Security
GenAI] Use stable IDs for Security AI Prompt saved object filenames
(#265301)\n\n## Summary\n\nResolves #237178.\n\nThe
`generate_security_ai_prompts_script.ts` script previously
generated\nsaved object filenames using a random UUID on every
invocation
(e.g.\n`security_ai_prompts-022f0559-929f-4b06-ad08-571fc9b768ca.json`).
This\nmade PR reviews noisy and required a `rm ./*.json` step when
copying\nfiles into the integration package.\n\nThis PR replaces
`uuidv4()` with a deterministic `generateStableId`\nfunction that builds
the ID from `promptGroupId`, `promptId`, and\noptionally `provider` and
`model` — all lowercased. Example
stable\nfilename:\n\n```\nsecurity_ai_prompts-aiassistant-systemprompt-openai.json\n```\n\n###
Changes\n\n- **Script**: replaced `uuidv4()` with
`generateStableId(prompt)` that\nderives a stable, lowercase ID from the
prompt's identifying fields.\nRemoved `uuid` import.\n- **Tests**: added
13 Jest unit tests for `generateStableId`,\n`generateSavedObject`, and
`generateSavedObjects`.\n- **README**: removed the `rm ./*.json` step
from the developer update\nflow — with stable filenames, `cp` overwrites
files in place without\nneeding to clear them first.\n\n### Migration
note\n\nThe first time the script runs after this change, the
integration repo\n(`elastic/integrations`) will still contain the old
UUID-named files. A\none-time `rm ./*.json` followed by `cp` in that
repo is needed to fully\nreplace them with stable-named files. After
that, the `rm` step is no\nlonger required.\n\n## Test plan\n\n- [x]
`node
scripts/jest\nx-pack/solutions/security/plugins/elastic_assistant/scripts/generate_security_ai_prompts_script.test.ts`\n—
13 tests pass\n- [x] `node scripts/check_changes.ts` — lint and
pre-commit checks pass\n- [x] Run `yarn generate-security-ai-prompts`
in\n`x-pack/solutions/security/plugins/elastic_assistant` and confirm
output\nfilenames are stable across multiple
invocations\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"6f23495f1b94f6a1fa1e5735ae00444164d770a4"}},"sourceBranch":"main","suggestedTargetBranches":["8.19","9.3","9.4"],"targetPullRequestStates":[{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.3","label":"v9.3.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.4","label":"v9.4.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.5.0","branchLabelMappingKey":"^v9.5.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/265301","number":265301,"mergeCommit":{"message":"[Security
GenAI] Use stable IDs for Security AI Prompt saved object filenames
(#265301)\n\n## Summary\n\nResolves #237178.\n\nThe
`generate_security_ai_prompts_script.ts` script previously
generated\nsaved object filenames using a random UUID on every
invocation
(e.g.\n`security_ai_prompts-022f0559-929f-4b06-ad08-571fc9b768ca.json`).
This\nmade PR reviews noisy and required a `rm ./*.json` step when
copying\nfiles into the integration package.\n\nThis PR replaces
`uuidv4()` with a deterministic `generateStableId`\nfunction that builds
the ID from `promptGroupId`, `promptId`, and\noptionally `provider` and
`model` — all lowercased. Example
stable\nfilename:\n\n```\nsecurity_ai_prompts-aiassistant-systemprompt-openai.json\n```\n\n###
Changes\n\n- **Script**: replaced `uuidv4()` with
`generateStableId(prompt)` that\nderives a stable, lowercase ID from the
prompt's identifying fields.\nRemoved `uuid` import.\n- **Tests**: added
13 Jest unit tests for `generateStableId`,\n`generateSavedObject`, and
`generateSavedObjects`.\n- **README**: removed the `rm ./*.json` step
from the developer update\nflow — with stable filenames, `cp` overwrites
files in place without\nneeding to clear them first.\n\n### Migration
note\n\nThe first time the script runs after this change, the
integration repo\n(`elastic/integrations`) will still contain the old
UUID-named files. A\none-time `rm ./*.json` followed by `cp` in that
repo is needed to fully\nreplace them with stable-named files. After
that, the `rm` step is no\nlonger required.\n\n## Test plan\n\n- [x]
`node
scripts/jest\nx-pack/solutions/security/plugins/elastic_assistant/scripts/generate_security_ai_prompts_script.test.ts`\n—
13 tests pass\n- [x] `node scripts/check_changes.ts` — lint and
pre-commit checks pass\n- [x] Run `yarn generate-security-ai-prompts`
in\n`x-pack/solutions/security/plugins/elastic_assistant` and confirm
output\nfilenames are stable across multiple
invocations\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"6f23495f1b94f6a1fa1e5735ae00444164d770a4"}}]}]
BACKPORT-->

Co-authored-by: Kenneth Kreindler <42113355+KDKHD@users.noreply.github.com>
@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Apr 28, 2026
@kibanamachine
Copy link
Copy Markdown
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.
cc: @KDKHD

1 similar comment
@kibanamachine
Copy link
Copy Markdown
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.
cc: @KDKHD

kibanamachine added a commit that referenced this pull request Apr 30, 2026
…ject filenames (#265301) (#265823)

# Backport

This will backport the following commits from `main` to `9.3`:
- [[Security GenAI] Use stable IDs for Security AI Prompt saved object
filenames (#265301)](#265301)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Kenneth
Kreindler","email":"42113355+KDKHD@users.noreply.github.com"},"sourceCommit":{"committedDate":"2026-04-27T15:23:37Z","message":"[Security
GenAI] Use stable IDs for Security AI Prompt saved object filenames
(#265301)\n\n## Summary\n\nResolves #237178.\n\nThe
`generate_security_ai_prompts_script.ts` script previously
generated\nsaved object filenames using a random UUID on every
invocation
(e.g.\n`security_ai_prompts-022f0559-929f-4b06-ad08-571fc9b768ca.json`).
This\nmade PR reviews noisy and required a `rm ./*.json` step when
copying\nfiles into the integration package.\n\nThis PR replaces
`uuidv4()` with a deterministic `generateStableId`\nfunction that builds
the ID from `promptGroupId`, `promptId`, and\noptionally `provider` and
`model` — all lowercased. Example
stable\nfilename:\n\n```\nsecurity_ai_prompts-aiassistant-systemprompt-openai.json\n```\n\n###
Changes\n\n- **Script**: replaced `uuidv4()` with
`generateStableId(prompt)` that\nderives a stable, lowercase ID from the
prompt's identifying fields.\nRemoved `uuid` import.\n- **Tests**: added
13 Jest unit tests for `generateStableId`,\n`generateSavedObject`, and
`generateSavedObjects`.\n- **README**: removed the `rm ./*.json` step
from the developer update\nflow — with stable filenames, `cp` overwrites
files in place without\nneeding to clear them first.\n\n### Migration
note\n\nThe first time the script runs after this change, the
integration repo\n(`elastic/integrations`) will still contain the old
UUID-named files. A\none-time `rm ./*.json` followed by `cp` in that
repo is needed to fully\nreplace them with stable-named files. After
that, the `rm` step is no\nlonger required.\n\n## Test plan\n\n- [x]
`node
scripts/jest\nx-pack/solutions/security/plugins/elastic_assistant/scripts/generate_security_ai_prompts_script.test.ts`\n—
13 tests pass\n- [x] `node scripts/check_changes.ts` — lint and
pre-commit checks pass\n- [x] Run `yarn generate-security-ai-prompts`
in\n`x-pack/solutions/security/plugins/elastic_assistant` and confirm
output\nfilenames are stable across multiple
invocations\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"6f23495f1b94f6a1fa1e5735ae00444164d770a4","branchLabelMapping":{"^v9.5.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:version","v8.19.0","v9.3.0","v9.4.0","v9.5.0"],"title":"[Security
GenAI] Use stable IDs for Security AI Prompt saved object
filenames","number":265301,"url":"https://github.com/elastic/kibana/pull/265301","mergeCommit":{"message":"[Security
GenAI] Use stable IDs for Security AI Prompt saved object filenames
(#265301)\n\n## Summary\n\nResolves #237178.\n\nThe
`generate_security_ai_prompts_script.ts` script previously
generated\nsaved object filenames using a random UUID on every
invocation
(e.g.\n`security_ai_prompts-022f0559-929f-4b06-ad08-571fc9b768ca.json`).
This\nmade PR reviews noisy and required a `rm ./*.json` step when
copying\nfiles into the integration package.\n\nThis PR replaces
`uuidv4()` with a deterministic `generateStableId`\nfunction that builds
the ID from `promptGroupId`, `promptId`, and\noptionally `provider` and
`model` — all lowercased. Example
stable\nfilename:\n\n```\nsecurity_ai_prompts-aiassistant-systemprompt-openai.json\n```\n\n###
Changes\n\n- **Script**: replaced `uuidv4()` with
`generateStableId(prompt)` that\nderives a stable, lowercase ID from the
prompt's identifying fields.\nRemoved `uuid` import.\n- **Tests**: added
13 Jest unit tests for `generateStableId`,\n`generateSavedObject`, and
`generateSavedObjects`.\n- **README**: removed the `rm ./*.json` step
from the developer update\nflow — with stable filenames, `cp` overwrites
files in place without\nneeding to clear them first.\n\n### Migration
note\n\nThe first time the script runs after this change, the
integration repo\n(`elastic/integrations`) will still contain the old
UUID-named files. A\none-time `rm ./*.json` followed by `cp` in that
repo is needed to fully\nreplace them with stable-named files. After
that, the `rm` step is no\nlonger required.\n\n## Test plan\n\n- [x]
`node
scripts/jest\nx-pack/solutions/security/plugins/elastic_assistant/scripts/generate_security_ai_prompts_script.test.ts`\n—
13 tests pass\n- [x] `node scripts/check_changes.ts` — lint and
pre-commit checks pass\n- [x] Run `yarn generate-security-ai-prompts`
in\n`x-pack/solutions/security/plugins/elastic_assistant` and confirm
output\nfilenames are stable across multiple
invocations\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"6f23495f1b94f6a1fa1e5735ae00444164d770a4"}},"sourceBranch":"main","suggestedTargetBranches":["8.19","9.3","9.4"],"targetPullRequestStates":[{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.3","label":"v9.3.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.4","label":"v9.4.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.5.0","branchLabelMappingKey":"^v9.5.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/265301","number":265301,"mergeCommit":{"message":"[Security
GenAI] Use stable IDs for Security AI Prompt saved object filenames
(#265301)\n\n## Summary\n\nResolves #237178.\n\nThe
`generate_security_ai_prompts_script.ts` script previously
generated\nsaved object filenames using a random UUID on every
invocation
(e.g.\n`security_ai_prompts-022f0559-929f-4b06-ad08-571fc9b768ca.json`).
This\nmade PR reviews noisy and required a `rm ./*.json` step when
copying\nfiles into the integration package.\n\nThis PR replaces
`uuidv4()` with a deterministic `generateStableId`\nfunction that builds
the ID from `promptGroupId`, `promptId`, and\noptionally `provider` and
`model` — all lowercased. Example
stable\nfilename:\n\n```\nsecurity_ai_prompts-aiassistant-systemprompt-openai.json\n```\n\n###
Changes\n\n- **Script**: replaced `uuidv4()` with
`generateStableId(prompt)` that\nderives a stable, lowercase ID from the
prompt's identifying fields.\nRemoved `uuid` import.\n- **Tests**: added
13 Jest unit tests for `generateStableId`,\n`generateSavedObject`, and
`generateSavedObjects`.\n- **README**: removed the `rm ./*.json` step
from the developer update\nflow — with stable filenames, `cp` overwrites
files in place without\nneeding to clear them first.\n\n### Migration
note\n\nThe first time the script runs after this change, the
integration repo\n(`elastic/integrations`) will still contain the old
UUID-named files. A\none-time `rm ./*.json` followed by `cp` in that
repo is needed to fully\nreplace them with stable-named files. After
that, the `rm` step is no\nlonger required.\n\n## Test plan\n\n- [x]
`node
scripts/jest\nx-pack/solutions/security/plugins/elastic_assistant/scripts/generate_security_ai_prompts_script.test.ts`\n—
13 tests pass\n- [x] `node scripts/check_changes.ts` — lint and
pre-commit checks pass\n- [x] Run `yarn generate-security-ai-prompts`
in\n`x-pack/solutions/security/plugins/elastic_assistant` and confirm
output\nfilenames are stable across multiple
invocations\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"6f23495f1b94f6a1fa1e5735ae00444164d770a4"}}]}]
BACKPORT-->

Co-authored-by: Kenneth Kreindler <42113355+KDKHD@users.noreply.github.com>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
@kibanamachine kibanamachine added v9.3.4 and removed backport missing Added to PRs automatically when the are determined to be missing a backport. labels Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels release_note:skip Skip the PR/issue when compiling release notes v8.19.0 v8.19.15 v9.3.5 v9.4.0 v9.5.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Security Solution] Consider updating the generate_security_ai_prompts_script.ts script to generate saved object filenames based on stable IDs

4 participants