Skip to content

refactor(engine): keep built-in probes self-contained - #127

Open
3mei wants to merge 4 commits into
yev/refactor/health-probes-own-folderfrom
yev/refactor/self-contained-built-in-probes
Open

3mei wants to merge 4 commits into
yev/refactor/health-probes-own-folderfrom
yev/refactor/self-contained-built-in-probes

Conversation

@3mei

@3mei 3mei commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

What changed and why

Built-in probes stay self-contained: no built-in imports another probe's module, each built-in package's imports of internal usersim modules are counted and can only go down, and the capability report's refs and the probe catalog follow the registered probes and scorers.

Builds on #126.

  • persona_to_tags in core (first commit). persona_to_tags, with the region, age, education and occupation tables it reads, is in core/persona_tags.py. sov_ai_facts, sov_ai_dynamic, sov_ai_multilingual_parity, safety_chat_pressure and safety_agentic import it from there, so no probe imports another probe's module for its persona tags; financial_services has its own persona_to_tags. Its tests are in tests/engine/core/test_persona_tags.py, and the sov_ai_facts tests check that its banks serve each UK nation and German Land.
  • Internal imports held to their counts (second commit). tests/test_probe_private_imports.py counts, for each built-in package, the names it imports from usersim modules other than usersim.extension, usersim.testing and its own package. A package over its allowance fails, so does an allowance above the count, and so does a package with no allowance. The authoring guide describes the check where it covers registering a built-in.
  • Capability refs from the registries (third commit). implementation_refs_for_capability gives each probe and scorer a capability names the file its registered class or function is defined in, so a probe or scorer that moves takes its ref along. A test checks that every probe and scorer a capability names resolves to a file.
  • The catalog follows the built-ins (fourth commit). A test checks that the catalog table in docs/probes.md has one row for each built-in probe and no other.

How it was verified

At each commit, on that commit's tree:

$ make check-all && make test && make smoke
All checks passed!
368 files already formatted
4657 passed in 90.88s (0:01:30)
All checks passed.

That is the first commit's tree; the second, third and fourth pass with 4660, 4661 and 4662 tests, their new tests included.

At the head:

$ make check-license-headers
🎉 All files have correct license headers!
$ make check-doc-links
✓ every relative link, and every link into this repository's main branch, resolves
$ make check-notebooks-clean
OK 4 notebook(s) carry no outputs
$ make check-dist
✓ installed package runs from a clean environment
$ make check-extensions
all extension seams work against an installed distribution
  • core/persona_tags.py holds, byte for byte, the 391 lines that leave sov_ai_facts/task_derivation.py.

  • The second commit's tests fail when a package imports a name its allowance does not count, and when an allowance is above its count:

    E       AssertionError: A built-in package imports more names from internal usersim modules than its allowance. Import them from usersim.extension, or keep them in the probe's own package: {'sov_ai_facts': [...]}
    E       AssertionError: lower each allowance to its package's count, or drop a removed package, (allowed, counted): {'sov_ai_facts': (23, 22)}
    
  • At the third commit, each of the 46 capabilities gets the same refs, in the same order, as at the base.

  • The fourth commit's test fails with a catalog row removed:

    E         At index 7 diff: 'safety_agentic' != 'identity_disclosure'
    
  • make health-check ran against a custom provider config for sov_ai_multilingual_parity in hi_Deva_IN, which picks its query by persona tags. It ended with ✓ simulate, eval and report all completed, and every model's requests show failed=0.

  • usersim simulate, then usersim eval --scorers auto, ran against the same config for safety_chat_pressure in ko_KR:

    judge: scored
    language_compliance: ok (error=None)
    refusal_basics: ok (error=None)
    response_shape: ok (error=None)
    safety_chat_pressure: ok (error=None)
    

Results impact

Conversations, prompts, scores and the capability report are unchanged.

3mei added 4 commits November 3, 2026 16:08
persona_to_tags, with the region, age, education and occupation tables it reads, is in core/persona_tags.py. sov_ai_facts, sov_ai_dynamic, sov_ai_multilingual_parity, safety_chat_pressure and safety_agentic import it from there, so no probe imports another probe's module for its persona tags, and the tags a persona gets are unchanged. financial_services has its own persona_to_tags.

Its tests are in tests/engine/core/test_persona_tags.py. The sov_ai_facts tests check that its banks serve each UK nation and German Land.

Signed-off-by: Yev Meyer <ymeyer@nvidia.com>
test_probe_private_imports counts, for each built-in package, the names it imports from usersim modules other than usersim.extension, usersim.testing and its own package, and holds each package to its count in _ALLOWED: a package over its allowance fails, so does an allowance above the count, and so does a package with no allowance. The authoring guide describes the check where it covers registering a built-in.

Signed-off-by: Yev Meyer <ymeyer@nvidia.com>
implementation_refs_for_capability gives each probe and scorer a capability names the file its registered class or function is defined in, so a probe or scorer that moves takes its ref along and a new one needs no entry. A test checks that every probe and scorer a capability names resolves to a file, and the shared-code label allowance for taxonomy/capabilities.py matches its 27 labels.

Signed-off-by: Yev Meyer <ymeyer@nvidia.com>
The catalog table in docs/probes.md has one row for each built-in probe and no other, so a probe added, renamed or removed without its row fails.

Signed-off-by: Yev Meyer <ymeyer@nvidia.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant