Skip to content

fix: don't let a missing ahocorasick_ner break OCP keyword registration - #552

Draft
JarbasAl wants to merge 1 commit into
devfrom
fix/ocp-keyword-soft-fail
Draft

fix: don't let a missing ahocorasick_ner break OCP keyword registration#552
JarbasAl wants to merge 1 commit into
devfrom
fix/ocp-keyword-soft-fail

Conversation

@JarbasAl

Copy link
Copy Markdown
Member

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

register_ocp_keyword in ovos_workshop/skills/common_play.py hard-depended on the optional ahocorasick_ner package. When it wasn't installed, calling the method raised an ImportError before the ovos.common_play.register_keyword bus message was ever emitted. That message is what tells the OCP classifier a skill owns a given keyword (an artist name, a movie title, and so on), so without it OCP never learns the skill's vocabulary and can't use it to disambiguate between media types. At least one consumer, the OCP media daemon, ended up reimplementing the same bus emit locally as a workaround.

The fix treats the local Aho-Corasick index as what it actually is: an optional optimization for in-process keyword matching, not a prerequisite for talking to OCP. _register_ocp_ner now always records the samples and, if ahocorasick_ner is missing, logs a one-time warning and returns instead of raising. register_ocp_keyword always reaches the bus emit with the same payload shape it always had. The large-sample-set path (20+ samples), which exports a CSV built from the local matcher, now falls back to sending the raw sample list directly if that export isn't possible, rather than losing the registration.

deregister_ocp_keyword was checked for the same failure mode and doesn't have one — the only NER-dependent call inside it is already commented out pending upstream support, so it was already safe.

Five new tests in test/unittests/skills/test_common_play_extended.py cover the fix: a sanity check that the emit still carries samples with the dependency present, the missing-dependency case (patching AhocorasickNER to None), an empty-samples edge case, the large-sample-set CSV-export fallback, and a check that the warning logs exactly once across repeated calls. All five were verified to fail against the pre-fix code (via a patch-file revert of the source only) and pass after the fix. The full suite runs at 624 passed both before and after, with no pre-existing failures on either side.

register_ocp_keyword raised ImportError when the optional ahocorasick_ner
extra was absent, so the ovos.common_play.register_keyword bus emit never
happened and OCP never learned the skill's keywords. The local NER index is
an optional optimization; the bus emit is the contract. Missing NER now logs
a one-time warning and the message still goes out with the same payload
shape, falling back from a CSV export to raw samples when the local matcher
can't be built.
@coderabbitai

coderabbitai Bot commented Aug 16, 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: 21ed424e-8754-4384-af12-e12e2d10cae1

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 16, 2026
@github-actions

github-actions Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

I've scrutinized every line of your PR. Here's the report. 🧐

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

📋 Repo Health

Scanning for any signs of code rot or decay. 🍄

✅ All required files present.

Latest Version: 9.5.2a1

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

🔒 Security (pip-audit)

Checking for any potential privacy concerns. 🕶️

✅ No known vulnerabilities found (74 packages scanned).

🔍 Lint

The automated pipeline is running smoothly. 🚂

ruff: issues found — see job log

🔨 Build Tests

Compiling thoughts and code into something real. 🧠

✅ All versions pass

Python Build Install Tests
3.10
3.11
3.12
3.13
3.14

Automatically generated, personally appreciated 💖

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