-
Notifications
You must be signed in to change notification settings - Fork 103
LCORE-3365: shields e2e #2558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
radofuchs
merged 7 commits into
lightspeed-core:main
from
radofuchs:LCORE_3365_shields_e2e
Aug 31, 2026
Merged
LCORE-3365: shields e2e #2558
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
cce3bb3
add e2e tests for shields
bd464b1
clean up the structure of the files
5e1baaa
clean up the structure of the files
768eb8c
Merge branch 'lightspeed-core:main' into LCORE_3365_shields_e2e
radofuchs 8bf2a66
clean up the info feature
365d506
skip the failing tests
69ab085
disable eval e2e job
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
28 changes: 28 additions & 0 deletions
28
tests/e2e/configuration/library-mode/lightspeed-stack-shields-empty.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # @cfg_shields | ||
| # No `shields` key at all: GET /v1/shields must return an empty list. | ||
| # See tests/e2e/features/shields.feature. | ||
| name: Lightspeed Core Service (LCS) | ||
| service: | ||
| host: 0.0.0.0 | ||
| port: 8080 | ||
| auth_enabled: false | ||
| workers: 1 | ||
| color_log: true | ||
| access_log: true | ||
| llama_stack: | ||
| # Library mode - embeds llama-stack as library | ||
| use_as_library_client: true | ||
| # Unified mode: run.yaml (materialized per provider by CI/the harness) | ||
| # is consumed as the synthesis profile instead of the legacy two-file path. | ||
| config: | ||
| profile: run.yaml | ||
| user_data_collection: | ||
| feedback_enabled: true | ||
| feedback_storage: "/tmp/data/feedback" | ||
| transcripts_enabled: true | ||
| transcripts_storage: "/tmp/data/transcripts" | ||
| authentication: | ||
| module: "noop" | ||
| inference: | ||
| default_provider: openai | ||
| default_model: gpt-4o-mini |
46 changes: 46 additions & 0 deletions
46
tests/e2e/configuration/library-mode/lightspeed-stack-shields-override-disabled.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # @cfg_shields | ||
| # Same shield setup as lightspeed-stack-shields.yaml, but with | ||
| # customization.disable_shield_ids_override enabled so that any client | ||
| # supplied `shield_ids` field on /query or /streaming_query is rejected | ||
| # with a 422. See tests/e2e/features/shields_overrides.feature. | ||
| name: Lightspeed Core Service (LCS) | ||
| service: | ||
| host: 0.0.0.0 | ||
| port: 8080 | ||
| auth_enabled: false | ||
| workers: 1 | ||
| color_log: true | ||
| access_log: true | ||
| llama_stack: | ||
| # Library mode - embeds llama-stack as library | ||
| use_as_library_client: true | ||
| # Unified mode: run.yaml (materialized per provider by CI/the harness) | ||
| # is consumed as the synthesis profile instead of the legacy two-file path. | ||
| config: | ||
| profile: run.yaml | ||
| user_data_collection: | ||
| feedback_enabled: true | ||
| feedback_storage: "/tmp/data/feedback" | ||
| transcripts_enabled: true | ||
| transcripts_storage: "/tmp/data/transcripts" | ||
| authentication: | ||
| module: "noop" | ||
| inference: | ||
| default_provider: openai | ||
| default_model: gpt-4o-mini | ||
| customization: | ||
| disable_shield_ids_override: true | ||
| shields: | ||
| - name: topic-guard | ||
| provider_id: question_validity | ||
| config: | ||
| model_id: openai/gpt-4o-mini | ||
| model_prompt: "Classify whether the following question is about OpenShift or Kubernetes. Reply with exactly one word: ${allowed} if it is about OpenShift or Kubernetes, or ${rejected} if it is not. Do not explain your answer or add any other text.\n\nQuestion: ${message}\nAnswer:" | ||
| invalid_question_response: "I can only answer questions about OpenShift." | ||
| - name: pii-redaction | ||
| provider_id: redaction | ||
| config: | ||
| rules: | ||
| - pattern: '\d+' | ||
| replacement: '[NUM]' | ||
| case_sensitive: false |
46 changes: 46 additions & 0 deletions
46
tests/e2e/configuration/library-mode/lightspeed-stack-shields.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # @cfg_shields | ||
| # LCORE-owned safety shields (not Llama Stack / OGX Safety API resources). | ||
| # Configures one shield of each supported type so GET /v1/shields can be | ||
| # asserted against both `question_validity` and `redaction` shapes. See | ||
| # tests/e2e/features/shields.feature. | ||
| name: Lightspeed Core Service (LCS) | ||
| service: | ||
| host: 0.0.0.0 | ||
| port: 8080 | ||
| auth_enabled: false | ||
| workers: 1 | ||
| color_log: true | ||
| access_log: true | ||
| llama_stack: | ||
| # Library mode - embeds llama-stack as library | ||
| use_as_library_client: true | ||
| # Unified mode: run.yaml (materialized per provider by CI/the harness) | ||
| # is consumed as the synthesis profile instead of the legacy two-file path. | ||
| config: | ||
| profile: run.yaml | ||
| user_data_collection: | ||
| feedback_enabled: true | ||
| feedback_storage: "/tmp/data/feedback" | ||
| transcripts_enabled: true | ||
| transcripts_storage: "/tmp/data/transcripts" | ||
| authentication: | ||
| module: "noop" | ||
| inference: | ||
| default_provider: openai | ||
| default_model: gpt-4o-mini | ||
| shields: | ||
| - name: topic-guard | ||
| provider_id: question_validity | ||
| config: | ||
| model_id: openai/gpt-4o-mini | ||
| # Must reference ${message}; string.Template silently drops the question | ||
| # otherwise (the classifier would never see what it's classifying). | ||
| model_prompt: "Classify whether the following question is about OpenShift or Kubernetes. Reply with exactly one word: ${allowed} if it is about OpenShift or Kubernetes, or ${rejected} if it is not. Do not explain your answer or add any other text.\n\nQuestion: ${message}\nAnswer:" | ||
| invalid_question_response: "I can only answer questions about OpenShift." | ||
| - name: pii-redaction | ||
| provider_id: redaction | ||
| config: | ||
| rules: | ||
| - pattern: '\d+' | ||
| replacement: '[NUM]' | ||
| case_sensitive: false |
26 changes: 26 additions & 0 deletions
26
tests/e2e/configuration/server-mode/lightspeed-stack-shields-empty.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # @cfg_shields | ||
| # No `shields` key at all: GET /v1/shields must return an empty list. | ||
| # See tests/e2e/features/shields.feature. | ||
| name: Lightspeed Core Service (LCS) | ||
| service: | ||
| host: 0.0.0.0 | ||
| port: 8080 | ||
| auth_enabled: false | ||
| workers: 1 | ||
| color_log: true | ||
| access_log: true | ||
| llama_stack: | ||
| # Server mode - connects to separate llama-stack service | ||
| use_as_library_client: false | ||
| url: http://${env.E2E_LLAMA_HOSTNAME}:8321 | ||
| api_key: xyzzy | ||
| user_data_collection: | ||
| feedback_enabled: true | ||
| feedback_storage: "/tmp/data/feedback" | ||
| transcripts_enabled: true | ||
| transcripts_storage: "/tmp/data/transcripts" | ||
| authentication: | ||
| module: "noop" | ||
| inference: | ||
| default_provider: openai | ||
| default_model: gpt-4o-mini |
44 changes: 44 additions & 0 deletions
44
tests/e2e/configuration/server-mode/lightspeed-stack-shields-override-disabled.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # @cfg_shields | ||
| # Same shield setup as lightspeed-stack-shields.yaml, but with | ||
| # customization.disable_shield_ids_override enabled so that any client | ||
| # supplied `shield_ids` field on /query or /streaming_query is rejected | ||
| # with a 422. See tests/e2e/features/shields_overrides.feature. | ||
| name: Lightspeed Core Service (LCS) | ||
| service: | ||
| host: 0.0.0.0 | ||
| port: 8080 | ||
| auth_enabled: false | ||
| workers: 1 | ||
| color_log: true | ||
| access_log: true | ||
| llama_stack: | ||
| # Server mode - connects to separate llama-stack service | ||
| use_as_library_client: false | ||
| url: http://${env.E2E_LLAMA_HOSTNAME}:8321 | ||
| api_key: xyzzy | ||
| user_data_collection: | ||
| feedback_enabled: true | ||
| feedback_storage: "/tmp/data/feedback" | ||
| transcripts_enabled: true | ||
| transcripts_storage: "/tmp/data/transcripts" | ||
| authentication: | ||
| module: "noop" | ||
| inference: | ||
| default_provider: openai | ||
| default_model: gpt-4o-mini | ||
| customization: | ||
| disable_shield_ids_override: true | ||
| shields: | ||
| - name: topic-guard | ||
| provider_id: question_validity | ||
| config: | ||
| model_id: openai/gpt-4o-mini | ||
| model_prompt: "Classify whether the following question is about OpenShift or Kubernetes. Reply with exactly one word: ${allowed} if it is about OpenShift or Kubernetes, or ${rejected} if it is not. Do not explain your answer or add any other text.\n\nQuestion: ${message}\nAnswer:" | ||
| invalid_question_response: "I can only answer questions about OpenShift." | ||
| - name: pii-redaction | ||
| provider_id: redaction | ||
| config: | ||
| rules: | ||
| - pattern: '\d+' | ||
| replacement: '[NUM]' | ||
| case_sensitive: false |
44 changes: 44 additions & 0 deletions
44
tests/e2e/configuration/server-mode/lightspeed-stack-shields.yaml
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # @cfg_shields | ||
| # LCORE-owned safety shields (not Llama Stack / OGX Safety API resources). | ||
| # Configures one shield of each supported type so GET /v1/shields can be | ||
| # asserted against both `question_validity` and `redaction` shapes. See | ||
| # tests/e2e/features/shields.feature. | ||
| name: Lightspeed Core Service (LCS) | ||
| service: | ||
| host: 0.0.0.0 | ||
| port: 8080 | ||
| auth_enabled: false | ||
| workers: 1 | ||
| color_log: true | ||
| access_log: true | ||
| llama_stack: | ||
| # Server mode - connects to separate llama-stack service | ||
| use_as_library_client: false | ||
| url: http://${env.E2E_LLAMA_HOSTNAME}:8321 | ||
| api_key: xyzzy | ||
| user_data_collection: | ||
| feedback_enabled: true | ||
| feedback_storage: "/tmp/data/feedback" | ||
| transcripts_enabled: true | ||
| transcripts_storage: "/tmp/data/transcripts" | ||
| authentication: | ||
| module: "noop" | ||
| inference: | ||
| default_provider: openai | ||
| default_model: gpt-4o-mini | ||
| shields: | ||
| - name: topic-guard | ||
| provider_id: question_validity | ||
| config: | ||
| model_id: openai/gpt-4o-mini | ||
| # Must reference ${message}; string.Template silently drops the question | ||
| # otherwise (the classifier would never see what it's classifying). | ||
| model_prompt: "Classify whether the following question is about OpenShift or Kubernetes. Reply with exactly one word: ${allowed} if it is about OpenShift or Kubernetes, or ${rejected} if it is not. Do not explain your answer or add any other text.\n\nQuestion: ${message}\nAnswer:" | ||
| invalid_question_response: "I can only answer questions about OpenShift." | ||
| - name: pii-redaction | ||
| provider_id: redaction | ||
| config: | ||
| rules: | ||
| - pattern: '\d+' | ||
| replacement: '[NUM]' | ||
| case_sensitive: false |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| Feature: Shields endpoint tests | ||
|
|
||
| Tests for the LCORE-owned GET /v1/shields catalog endpoint. These shields | ||
| (question_validity, redaction) are configured directly in | ||
| lightspeed-stack.yaml; they are not Llama Stack / OGX Safety API resources. | ||
| See docs/user_doc/shields_guide.md for the full shield configuration and | ||
| runtime-behavior reference. | ||
|
|
||
| Background: | ||
| Given The service is started locally | ||
| And The system is in default state | ||
| And REST API service prefix is /v1 | ||
| And the Lightspeed stack configuration directory is "tests/e2e/configuration" | ||
|
|
||
| @cfg_shields | ||
| Scenario: Shields endpoint returns every configured shield type | ||
| Given The service uses the lightspeed-stack-shields.yaml configuration | ||
| And The service is restarted | ||
| When I access REST API endpoint "shields" using HTTP GET method | ||
| Then The status code of the response is 200 | ||
| And The body of the response is the following | ||
| """ | ||
| { | ||
| "shields": [ | ||
| { | ||
| "name": "topic-guard", | ||
| "provider_id": "question_validity", | ||
| "type": "shield", | ||
| "config": { | ||
| "model_id": "openai/gpt-4o-mini", | ||
| "model_prompt": "Classify whether the following question is about OpenShift or Kubernetes. Reply with exactly one word: ${allowed} if it is about OpenShift or Kubernetes, or ${rejected} if it is not. Do not explain your answer or add any other text.\n\nQuestion: ${message}\nAnswer:", | ||
| "invalid_question_response": "I can only answer questions about OpenShift." | ||
| } | ||
| }, | ||
| { | ||
| "name": "pii-redaction", | ||
| "provider_id": "redaction", | ||
| "type": "shield", | ||
| "config": { | ||
| "rules": [ | ||
| { | ||
| "pattern": "\\d+", | ||
| "replacement": "[NUM]", | ||
| "case_sensitive": null | ||
| } | ||
| ], | ||
| "case_sensitive": false | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| """ | ||
|
|
||
| @cfg_shields | ||
| Scenario: Shields endpoint returns an empty list when no shields are configured | ||
| Given The service uses the lightspeed-stack-shields-empty.yaml configuration | ||
| And The service is restarted | ||
| When I access REST API endpoint "shields" using HTTP GET method | ||
| Then The status code of the response is 200 | ||
| And The body of the response is the following | ||
| """ | ||
| { | ||
| "shields": [] | ||
| } | ||
| """ |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.