[Tracker]
Update Summary: [One-line status update for stakeholders]
Short Description: [One-line issue summary for stakeholders]
Check-in Date: MM/DD/YYYY
Metadata is used by the AI Tracker. Docs and additional fields here.
[/Tracker]

Problem/Motivation

The config schema for Guardrail and Guardrail Set config entities in ai.schema.yml is incomplete. Several properties and plugin-specific schema definitions are missing, which causes strict config schema validation to fail.

The following issues exist in the current schema:

  1. The ai.ai_guardrail.* config entity is missing the guardrail_settings property. Every guardrail config entity stores its plugin-specific settings under this key, but the schema does not declare it.
  2. There is no ai.guardrail.settings.* wildcard fallback schema for guardrail plugin settings. This is needed as the base type for dynamic plugin-specific schema resolution.
  3. The existing RegexpGuardrail plugin (regexp_guardrail) has no corresponding ai.guardrail.settings.regexp_guardrail schema definition — its regexp_pattern and violation_message configuration keys are completely undeclared.
  4. The existing RestrictToTopic plugin (restrict_to_topic) has no corresponding ai.guardrail.settings.restrict_to_topic schema definition — its valid_topics, invalid_topics, message overrides, and LLM provider/model configuration keys are completely undeclared.
  5. The ai.ai_guardrail_set.* config entity is missing the stop_threshold property. The entity stores this float value but the schema does not declare it.

Steps to reproduce

  1. Enable the AI module and create any guardrail config entity (e.g. a RegexpGuardrail or RestrictToTopic guardrail).
  2. Run config validation with strict schema checking enabled (e.g. via kernel tests with $strictConfigSchema = TRUE).
  3. Schema validation errors will appear for the missing properties and plugin settings.

Proposed resolution

Add the missing schema definitions to config/schema/ai.schema.yml:

  • Add guardrail_settings to ai.ai_guardrail.* with a dynamic type reference: ai.guardrail.settings.[%parent.guardrail]
  • Add ai.guardrail.settings.* as a wildcard fallback mapping
  • Add ai.guardrail.settings.regexp_guardrail with regexp_pattern and violation_message
  • Add ai.guardrail.settings.restrict_to_topic with valid_topics, invalid_topics, message overrides, llm_provider, llm_model, and llm_config
  • Add stop_threshold (float) to ai.ai_guardrail_set.*

AI usage

[x] AI Assisted Issue
Split out from #3582856 (comment #5 / comment #9) — the schema fixes were discovered while adding the InputLengthLimit guardrail plugin and should be backported independently as a bug fix.

Issue fork ai-3583785

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

ahmad khader created an issue. See original summary.

ahmad khader’s picture

Issue summary: View changes

ahmad khader’s picture

Moved to RTBC status, as it has already been reviewed in the parent issue. This MR is being backported independently as a bug fix.

marcus_johansson’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: +needs backport to 1.3.x, +needs forward port

Getting merged

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.