[Security GenAI] Use stable IDs for Security AI Prompt saved object filenames#265301
Merged
KDKHD merged 5 commits intoelastic:mainfrom Apr 27, 2026
Merged
Conversation
…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.
Member
Author
|
/ci |
`naturalLanguageESQLTool` → `natural-language-esql-tool`, rather than collapsing everything to `naturallanguageesqltool`.
Member
Author
|
Files look like this now: |
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.
Member
Author
|
/ci |
andrew-goldstein
approved these changes
Apr 27, 2026
Contributor
andrew-goldstein
left a comment
There was a problem hiding this comment.
Thanks @KDKHD, this is a huge improvement to devex and review process!
LGTM 🚀
Contributor
💛 Build succeeded, but was flaky
Failed CI StepsMetrics [docs]
|
Contributor
|
Starting backport for target branches: 8.19, 9.3, 9.4 https://github.com/elastic/kibana/actions/runs/25003837492 |
This was referenced Apr 27, 2026
Contributor
💚 All backports created successfully
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>
8 tasks
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. |
1 similar comment
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. |
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolves #237178.
The
generate_security_ai_prompts_script.tsscript 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 arm ./*.jsonstep when copying files into the integration package.This PR replaces
uuidv4()with a deterministicgenerateStableIdfunction that builds the ID frompromptGroupId,promptId, and optionallyproviderandmodel— all lowercased. Example stable filename:Changes
uuidv4()withgenerateStableId(prompt)that derives a stable, lowercase ID from the prompt's identifying fields. Removeduuidimport.generateStableId,generateSavedObject, andgenerateSavedObjects.rm ./*.jsonstep from the developer update flow — with stable filenames,cpoverwrites 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-timerm ./*.jsonfollowed bycpin that repo is needed to fully replace them with stable-named files. After that, thermstep 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 passnode scripts/check_changes.ts— lint and pre-commit checks passyarn generate-security-ai-promptsinx-pack/solutions/security/plugins/elastic_assistantand confirm output filenames are stable across multiple invocations