Skip to content

fix: use the shared language-match helper for dialect configs - #428

Draft
JarbasAl wants to merge 1 commit into
devfrom
fix/lang-distance-inclusive
Draft

fix: use the shared language-match helper for dialect configs#428
JarbasAl wants to merge 1 commit into
devfrom
fix/lang-distance-inclusive

Conversation

@JarbasAl

Copy link
Copy Markdown
Member

🤖 Auto-generated by Claude Opus 5 (claude-opus-5) via Claude Code — NOT human-reviewed. Verify before acting.

What

ovos_plugin_manager/utils/config.py compared a language distance by hand in
two places:

  • get_valid_plugin_configs (dialect filter)
  • get_plugin_language_configs (macro filter)

Both read if lang_distance(...) < 10. Both now call lang_matches, which
owns the comparison and the threshold.

Why

ovos_spec_tools.DEFAULT_MAX_LANGUAGE_DISTANCE is 10. A < 10 comparison
admits 0 to 9 and rejects 10 itself.

langcodes gives a distance of exactly 10 to a language measured against its
macrolanguage tag: tag_distance('arz', 'ar') and tag_distance('wuu', 'zh')
are both 10. Its own closest_match filters with distance <= max_distance.
The hand-rolled < therefore excluded the one relation the number 10 names —
which is the relation the second call site is literally named after
(macro).

Behaviour change

A plugin that ships a config for a macrolanguage now offers it to a request in
a member language. A TTS or STT plugin with an ar config is offered for an
arz request; a plugin with a zh config is offered for wuu. The dialect
priority boost applies as it already does for regional variants.

Not every variety moves. Only pairs langcodes scores at 10 or less change;
ary and apc against ar score 14 and are still excluded, as are af
against nl (24) and yue against zh (64).

Tests

New file test/unittests/test_lang_distance_boundary.py pins both sides:

  • arz/ar and wuu/zh are offered.
  • ar-SA/ar, en-AU/en-GB, pt-BR/pt-PT are offered.
  • en/zh, es/fr, fr-CH/de-CH, af/nl are not offered.

RED, with the < 10 comparisons restored:

SUBFAILED(member='arz') ...::TestValidPluginConfigLangBoundary::test_macrolanguage_config_is_offered
SUBFAILED(member='wuu') ...::TestValidPluginConfigLangBoundary::test_macrolanguage_config_is_offered
2 failed, 3 passed, 7 subtests passed

GREEN, in isolation: 3 passed, 9 subtests passed.
In-suite with test/unittests/test_utils.py: 30 passed, 9 subtests passed.

No pytest.importorskip at any level in the new file.

Verified against source

  • Both < 10 sites — read from origin/dev.
  • distance <= max_distance in langcodes.closest_match, and the
    tag_distance macrolanguage docstring — read from the installed langcodes.
  • The distances 10 / 14 / 24 / 64 quoted above — computed by calling
    ovos_spec_tools.language.lang_distance, not copied from documentation.
  • RED and GREEN output — produced by running pytest.

Dependency

pyproject.toml pins ovos-spec-tools[langcodes]>=0.0.1a2. lang_matches
needs the inclusive bound from OpenVoiceOS/ovos-spec-tools#96, so the floor
must be raised to the release carrying it before this merges. That release does
not exist yet, so the bump is not in this branch.

Merge order

  1. fix: accept a language distance equal to the threshold ovos-spec-tools#96
  2. release ovos-spec-tools, then raise the floor pin here
  3. this PR

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a28c20cc-6b02-4827-bfaf-77a7775f4bc9

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the fix label Aug 10, 2026
@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Ready for review! The automated tests have finished. ✅

I've aggregated the results of the automated checks for this PR below.

🔍 Lint

The data is in, and it's looking interesting! 🧐

ruff: issues found — see job log

🔒 Security (pip-audit)

A detailed security audit of your contribution. 📝

✅ No known vulnerabilities found (65 packages scanned).

🏷️ Release Preview

The release banner is being designed! 🎨

Current: 2.11.1a2Next: 2.11.2a1

Signal Value
Label fix
PR title fix: use the shared language-match helper for dialect configs
Bump build

✅ PR title follows conventional commit format.


🚀 Release Channel Compatibility

Predicted next version: 2.11.2a1

Channel Status Note Current Constraint
Stable Too new (must be <0.10.0) ovos-plugin-manager>=0.9.0,<0.10.0
Testing Compatible ovos-plugin-manager>=1.0.3,<3.0.0
Alpha Compatible ovos-plugin-manager>=2.11.1a2

📋 Repo Health

I've performed a health check on the project. 🏥

✅ All required files present.

Latest Version: 2.11.1a2

ovos_plugin_manager/version.py — Version file
README.md — README
LICENSE — License file
pyproject.toml — pyproject.toml
⚠️ setup.py — setup.py
CHANGELOG.md — Changelog
ovos_plugin_manager/version.py has valid version block markers

⚖️ License Check

I've checked the genealogical tree of your licenses. 🌳

✅ No license violations found.

Policy: Apache 2.0 (universal donor). StrongCopyleft / NetworkCopyleft / WeakCopyleft / Other / Error categories fail. MPL allowed.

📊 Coverage

Checking the insulation of our logic. 🏠

82.7% total coverage

⚠️ Some tests failed — coverage figures may be incomplete.

Files below 80% coverage (23 files)
File Coverage Missing lines
ovos_plugin_manager/utils/audio.py 27.0% 65
ovos_plugin_manager/templates/embeddings.py 27.5% 187
ovos_plugin_manager/hardware/__init__.py 31.6% 13
ovos_plugin_manager/__init__.py 33.3% 4
ovos_plugin_manager/templates/gui.py 39.0% 25
ovos_plugin_manager/audio.py 40.5% 22
ovos_plugin_manager/templates/language.py 58.0% 21
ovos_plugin_manager/audio2ipa.py 58.1% 13
ovos_plugin_manager/gui.py 62.5% 15
ovos_plugin_manager/postag.py 63.0% 17
ovos_plugin_manager/segmentation.py 63.0% 17
ovos_plugin_manager/tokenization.py 63.0% 17
ovos_plugin_manager/templates/solvers.py 68.7% 82
ovos_plugin_manager/coreference.py 69.2% 16
ovos_plugin_manager/plugin_entry.py 69.5% 46
ovos_plugin_manager/templates/ocp.py 72.2% 5
ovos_plugin_manager/templates/segmentation.py 73.7% 5
ovos_plugin_manager/templates/audio2ipa.py 75.0% 3
ovos_plugin_manager/templates/postag.py 75.0% 5
ovos_plugin_manager/media_provider.py 75.7% 9
ovos_plugin_manager/templates/hotwords.py 77.4% 7
ovos_plugin_manager/persona.py 77.8% 2
ovos_plugin_manager/templates/keywords.py 78.9% 4

Full report: download the coverage-report artifact.

🔨 Build Tests

Ensuring the gears are properly lubricated. 💧

Python Build Install Tests
3.10 ⚠️
3.11 ⚠️
3.12 ⚠️
3.13 ⚠️
3.14 ⚠️

❌ 3.10: Install OK, tests failed
❌ 3.11: Install OK, tests failed
❌ 3.12: Install OK, tests failed
❌ 3.13: Install OK, tests failed
❌ 3.14: Install OK, tests failed
Check job logs for details.


Automatically generated, personally appreciated 💖

Both dialect filters compared a distance by hand; lang_matches owns that
comparison and its threshold.
@JarbasAl
JarbasAl force-pushed the fix/lang-distance-inclusive branch from fe0e8a8 to 9508a6c Compare August 11, 2026 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant