Fix: Guardrail and Guardrail Set config entities have incomplete config schema
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3583785. -->
Reported by: [ahmad khader](https://www.drupal.org/user/3727855)
Related to !1473
>>>
<p>[Tracker]<br>
<strong>Update Summary: </strong>[One-line status update for stakeholders]<br>
<strong>Short Description: </strong>[One-line issue summary for stakeholders]<br>
<strong>Check-in Date: </strong>MM/DD/YYYY<br>
<em>Metadata is used by the <a href="https://www.drupalstarforge.ai/" title="AI Tracker">AI Tracker.</a> Docs and additional fields <a href="https://www.drupalstarforge.ai/ai-dashboard/docs" title="AI Issue Tracker Documentation">here</a>.</em><br>
[/Tracker]</p>
<h3>Problem/Motivation</h3>
<p>The config schema for Guardrail and Guardrail Set config entities in <code>ai.schema.yml</code> is incomplete. Several properties and plugin-specific schema definitions are missing, which causes strict config schema validation to fail.</p>
<p>The following issues exist in the current schema:</p>
<ol>
<li>The <code>ai.ai_guardrail.*</code> config entity is missing the <code>guardrail_settings</code> property. Every guardrail config entity stores its plugin-specific settings under this key, but the schema does not declare it.</li>
<li>There is no <code>ai.guardrail.settings.*</code> wildcard fallback schema for guardrail plugin settings. This is needed as the base type for dynamic plugin-specific schema resolution.</li>
<li>The existing <code>RegexpGuardrail</code> plugin (<code>regexp_guardrail</code>) has no corresponding <code>ai.guardrail.settings.regexp_guardrail</code> schema definition — its <code>regexp_pattern</code> and <code>violation_message</code> configuration keys are completely undeclared.</li>
<li>The existing <code>RestrictToTopic</code> plugin (<code>restrict_to_topic</code>) has no corresponding <code>ai.guardrail.settings.restrict_to_topic</code> schema definition — its <code>valid_topics</code>, <code>invalid_topics</code>, message overrides, and LLM provider/model configuration keys are completely undeclared.</li>
<li>The <code>ai.ai_guardrail_set.*</code> config entity is missing the <code>stop_threshold</code> property. The entity stores this float value but the schema does not declare it.</li>
</ol>
<h3>Steps to reproduce</h3>
<ol>
<li>Enable the AI module and create any guardrail config entity (e.g. a RegexpGuardrail or RestrictToTopic guardrail).</li>
<li>Run config validation with strict schema checking enabled (e.g. via kernel tests with <code>$strictConfigSchema = TRUE</code>).</li>
<li>Schema validation errors will appear for the missing properties and plugin settings.</li>
</ol>
<h3>Proposed resolution</h3>
<p>Add the missing schema definitions to <code>config/schema/ai.schema.yml</code>:</p>
<ul>
<li>Add <code>guardrail_settings</code> to <code>ai.ai_guardrail.*</code> with a dynamic type reference: <code>ai.guardrail.settings.[%parent.guardrail]</code></li>
<li>Add <code>ai.guardrail.settings.*</code> as a wildcard fallback mapping</li>
<li>Add <code>ai.guardrail.settings.regexp_guardrail</code> with <code>regexp_pattern</code> and <code>violation_message</code></li>
<li>Add <code>ai.guardrail.settings.restrict_to_topic</code> with <code>valid_topics</code>, <code>invalid_topics</code>, message overrides, <code>llm_provider</code>, <code>llm_model</code>, and <code>llm_config</code></li>
<li>Add <code>stop_threshold</code> (float) to <code>ai.ai_guardrail_set.*</code></li>
</ul>
<h3>AI usage</h3>
<p>[x] AI Assisted Issue<br>
Split out from <a href="https://www.drupal.org/project/ai/issues/3582856">#3582856</a> (comment #5 / comment #9) — the schema fixes were discovered while adding the InputLengthLimit guardrail plugin and should be backported independently as a bug fix.</p>
> Related issue: [Issue #3582856](https://www.drupal.org/node/3582856)
issue