Skip to content

feat: add Rust voiceprint scoring kernel#36

Merged
MapleEve merged 3 commits into
mainfrom
feat/0.8.1-voiceprint-rust-kernel
Jun 9, 2026
Merged

feat: add Rust voiceprint scoring kernel#36
MapleEve merged 3 commits into
mainfrom
feat/0.8.1-voiceprint-rust-kernel

Conversation

@MapleEve

@MapleEve MapleEve commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Summary

  • add an optional Rust voiceprint scoring kernel behind RUST_KERNEL_MODE=required
  • keep Python scoring as the default path and preserve the public voiceprint result contract
  • fail closed on Rust bridge import, call, top-level response, candidate response, and non-finite score errors
  • extend the Rust heavy gate Docker smoke to exercise the voiceprint kernel

Validation

  • python -m pytest tests/unit -q
  • python -m pytest tests/test_voiceprint_db.py -q
  • python -m pytest tests/unit/test_voiceprint_scoring_kernel.py tests/unit/test_kernel_bridge.py tests/test_voiceprint_db.py -q
  • python -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 -q
  • cargo test --manifest-path crates/voscript_core/Cargo.toml
  • cargo clippy --manifest-path crates/voscript_core/Cargo.toml --features python-bindings --all-targets -- -D warnings
  • cargo fmt --manifest-path crates/voscript_core/Cargo.toml -- --check
  • cargo check --manifest-path crates/voscript_core/Cargo.toml --features python-bindings
  • ruff format --check app/ tests/unit/test_kernel_bridge.py tests/unit/test_voiceprint_scoring_kernel.py tests/test_voiceprint_db.py
  • ruff check app/ tests/unit/test_kernel_bridge.py tests/unit/test_voiceprint_scoring_kernel.py tests/test_voiceprint_db.py --ignore E501
  • git diff --check
  • public release scan passed

Notes

  • Live API E2E was not counted locally because the current shell did not provide live service credentials; CI heavy gate should validate Rust wheel and Docker packaging on PR open.

@codecov

codecov Bot commented Jun 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.89189% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.59%. Comparing base (4ecfdbe) to head (b6ca0b8).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
app/voiceprints/scoring.py 88.17% 11 Missing ⚠️
app/voiceprints/db.py 85.71% 4 Missing ⚠️
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     
Flag Coverage Δ
unit 91.59% <91.89%> (+0.20%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@MapleEve MapleEve marked this pull request as ready for review June 9, 2026 14:41
Copilot AI review requested due to automatic review settings June 9, 2026 14:41
@claude

claude Bot commented Jun 9, 2026

Copy link
Copy Markdown

Claude encountered an error after 0s —— View job


I'll analyze this and get back to you.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_core version to 0.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.

Comment on lines +288 to +292
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);
Comment on lines +334 to +336
let Some(normalized_embedding) = normalize(embedding)? else {
return Err("voiceprint AS-norm embedding must not be zero vector".to_string());
};
Comment on lines +93 to +94
if not isinstance(result["reason"], str) or not result["reason"]:
raise RustKernelBridgeError("Rust voiceprint_score reason must be non-empty")
@MapleEve MapleEve marked this pull request as draft June 9, 2026 14:53
@MapleEve MapleEve marked this pull request as ready for review June 9, 2026 14:53
@MapleEve MapleEve merged commit 259f0bb into main Jun 9, 2026
10 of 11 checks passed
@MapleEve MapleEve deleted the feat/0.8.1-voiceprint-rust-kernel branch June 9, 2026 15:07
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.

2 participants