Skip to content

DomainAwarePolicies is embedded nowhere: 8 per-domain policy keys are silently dropped (incl. jailbreak_threshold, pii_threshold) #2771

Description

@ankit373

What happened

DomainAwarePolicies and the four policy types it inlines are declared but embedded in nothing, so the
13 yaml keys they define are never parsed from any config. Six of those keys are set in configs in this
repo, including per-category tuning in bench/.

src/semantic-router/pkg/config/signal_config.go:298:

type DomainAwarePolicies struct {
	SystemPromptPolicy    `yaml:",inline"`
	SemanticCachingPolicy `yaml:",inline"`
	JailbreakPolicy       `yaml:",inline"`
	PIIDetectionPolicy    `yaml:",inline"`
}

Repo-wide, non-test, excluding the declaration itself:

type references
DomainAwarePolicies 0
SystemPromptPolicy 0
SemanticCachingPolicy 0
JailbreakPolicy 0
PIIDetectionPolicy 0

Nothing in src/semantic-router, deploy/operator or the dashboard embeds or reads them, and each of
these yaml keys is defined on exactly one Go field, so there is no second, reachable struct picking them up.

Where it already bites

bench/cpu-vs-gpu/config-bench-candle.yaml sets per-category caching policy 6 times:

      - name: psychology
        system_prompt: You are a psychology expert with deep knowledge of ...
        semantic_cache_enabled: true
        semantic_cache_similarity_threshold: 0.92

with 0.75, 0.92 and 0.95 used across categories. All of it is dropped, so the benchmark runs every
category on the same global cache settings rather than the per-category ones it declares.

system_prompt on the sibling line is honoured (it is a field on a reachable struct), which is what
makes this hard to spot: adjacent keys in the same block behave differently.

Affected keys

system_prompt_enabled, system_prompt_mode, semantic_cache_enabled,
semantic_cache_similarity_threshold, jailbreak_enabled, jailbreak_threshold, pii_enabled,
pii_threshold.

jailbreak_threshold and pii_threshold are the ones I would prioritise. An operator tightening a
jailbreak or PII threshold for a specific domain currently gets the global value with no warning.

Note on the unknown-field linter

WarnUnknownFields does not flag these, so they are silent at startup too. That is consistent with the
blind spot I reported on #2469: the collector does not appear to reach this level of the tree.

Fix

Two directions and I don't want to pick for you:

  1. Wire it up. Embed DomainAwarePolicies where per-category policy is resolved and honour the
    thresholds. This is feature work and needs a decision on precedence against the global values.
  2. Remove it. Delete the orphaned types and the keys from bench/. Behaviour-neutral, but it
    removes surface the bench configs are already written against.

Happy to send either. Found while working on #2767/#2769.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions