feat: add Rust voiceprint scoring kernel#36
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #36 +/- ##
==========================================
+ Coverage 91.39% 91.59% +0.20%
==========================================
Files 79 79
Lines 3149 3333 +184
==========================================
+ Hits 2878 3053 +175
- Misses 271 280 +9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
|
Claude encountered an error after 0s —— View job I'll analyze this and get back to you. |
There was a problem hiding this comment.
Pull request overview
This PR introduces a Rust implementation of the voiceprint scoring kernel (selected only when RUST_KERNEL_MODE=required), while keeping the Python scoring behavior as the “golden oracle” and preserving the public voiceprint decision contract.
Changes:
- Added a Rust voiceprint scoring kernel (
voscript_core::voiceprint) with Python bindings and a fail-closed Python bridge (providers.kernel_bridge.voiceprint_score). - Extended voiceprint scoring tests (Python oracle + Rust golden cases) and updated DB identify flow to route scoring through the Rust kernel when required.
- Updated docs, CI heavy-gate smoke, and bumped
voscript_coreversion to0.8.1.
Reviewed changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
tests/unit/test_voiceprint_scoring_kernel.py |
Adds Python oracle golden tests plus Rust bridge response-validation tests. |
tests/unit/test_kernel_bridge.py |
Updates extension smoke expectations for version 0.8.1. |
tests/test_voiceprint_db.py |
Adds DB-level tests to ensure Rust routing + fail-closed behavior in required mode. |
doc/configuration.zh.md |
Documents that the currently selected Rust path is voiceprint scoring. |
doc/configuration.en.md |
Documents that the currently selected Rust path is voiceprint scoring. |
doc/changelog.zh.md |
Adds changelog entries for the Rust voiceprint scoring kernel and extended tests. |
doc/changelog.en.md |
Adds changelog entries for the Rust voiceprint scoring kernel and extended tests. |
crates/voscript_core/tests/voiceprint_scoring.rs |
Adds Rust-side golden tests for voiceprint scoring behavior. |
crates/voscript_core/src/voiceprint.rs |
Implements the Rust voiceprint scoring kernel logic (raw + AS-norm). |
crates/voscript_core/src/lib.rs |
Exposes the Rust kernel and adds the voiceprint_score PyO3 binding. |
crates/voscript_core/Cargo.toml |
Bumps voscript_core to 0.8.1. |
Cargo.lock |
Updates lockfile for the voscript_core version bump. |
app/voiceprints/scoring.py |
Introduces a Python “oracle” API/contract for scoring candidates. |
app/voiceprints/db.py |
Routes identify scoring through Rust kernel when required, and builds Rust payloads. |
app/providers/kernel_bridge/runtime.py |
Adds fail-closed Rust bridge call + response validation for voiceprint_score. |
app/providers/kernel_bridge/__init__.py |
Exports voiceprint_score from the kernel bridge package. |
.github/workflows/rust-foundation-heavy.yml |
Ensures clippy runs with python-bindings and smoke-tests voiceprint_score in Docker. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| for embedding in cohort { | ||
| let Some(vector) = normalize(embedding)? else { | ||
| return Err("voiceprint cohort embeddings must not be zero vectors".to_string()); | ||
| }; | ||
| normalized.push(vector); |
| let Some(normalized_embedding) = normalize(embedding)? else { | ||
| return Err("voiceprint AS-norm embedding must not be zero vector".to_string()); | ||
| }; |
| if not isinstance(result["reason"], str) or not result["reason"]: | ||
| raise RustKernelBridgeError("Rust voiceprint_score reason must be non-empty") |
Summary
RUST_KERNEL_MODE=requiredValidation
python -m pytest tests/unit -qpython -m pytest tests/test_voiceprint_db.py -qpython -m pytest tests/unit/test_voiceprint_scoring_kernel.py tests/unit/test_kernel_bridge.py tests/test_voiceprint_db.py -qpython -m pytest tests/unit/test_audio_layers.py::test_voiceprint_match_provider_uses_identify_threshold_when_supplied tests/unit/test_provider_registry.py::test_default_providers_are_listed_and_resolvable tests/unit/test_pipeline_runner.py::test_runner_dispatches_pipeline_steps_through_provider_registry -qcargo test --manifest-path crates/voscript_core/Cargo.tomlcargo clippy --manifest-path crates/voscript_core/Cargo.toml --features python-bindings --all-targets -- -D warningscargo fmt --manifest-path crates/voscript_core/Cargo.toml -- --checkcargo check --manifest-path crates/voscript_core/Cargo.toml --features python-bindingsruff format --check app/ tests/unit/test_kernel_bridge.py tests/unit/test_voiceprint_scoring_kernel.py tests/test_voiceprint_db.pyruff check app/ tests/unit/test_kernel_bridge.py tests/unit/test_voiceprint_scoring_kernel.py tests/test_voiceprint_db.py --ignore E501git diff --checkNotes