testsAndMisc/docs/superpowers/contracts/transcribe-diarize-tests-2026-08-17.json
Krzysztof kuhy Rudnicki fb51e991fe _transcribe_diarize: cover 0% -> 100% before splitting
The largest untested Python file left in the repo, at 356 lines against the
cap. Tests land first so the split that follows is verified against tests
that predate the seam.

63 tests: duration probing through both ffmpeg paths, the transcode fallback
and temp-file cleanup, audio loading's three outcomes, linear resampling,
cosine k-means, the ECAPA classifier loader, per-segment embedding
extraction, and diarize_segments end to end.

numpy is real here, not a double. It is a declared dependency, and the core
of this file is clustering maths - assertions against a mocked numpy would
prove nothing about whether two speakers actually get two labels. The
_try_import seam passes numpy through while stubbing torch and speechbrain,
so the tests still run in CI with neither installed. The clustering tests
assert real properties: two opposed groups separate, magnitude is ignored
because the metric is cosine, and a fixed seed reproduces.

The last three coverage gaps were _load_audio's ffmpeg fallback in both
outcomes, the minimum-slice widening, and the zero-iteration k-means branch.

Split across six test modules after two intermediate arrangements went over
the cap, and one move silently broke a test by separating it from its
doubles - caught by the test count holding at 63 through every rearrangement.
338 tests pass in the directory, up from 275 by exactly the 63 added.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011w2Pj4Ek3ZNMQVYcFHgXDY
2026-08-17 13:54:04 +02:00

19 lines
1.4 KiB
JSON

{
"title": "Cover _transcribe_diarize.py before splitting it",
"objective": "_transcribe_diarize.py is 356 lines against a 250-line cap and was completely untested - the largest untested Python file left in the repo. This commit raises it to 100% line and branch coverage first, so the following split can be verified against tests that predate the seam. numpy is real here rather than mocked, because the file's core is clustering maths and a mocked numpy would make those assertions vacuous.",
"acceptance_criteria": [
"_transcribe_diarize.py reaches 100% line and branch coverage, from 0%",
"_transcribe_diarize.py is byte-identical to HEAD - this commit adds tests only",
"The tests run without torch, speechbrain, soundfile or ffmpeg present",
"The clustering tests assert real separation properties, not that a mock was called",
"No suppression of any kind",
"Every new test file is under the 250-line cap"
],
"out_of_scope": [
"The split of _transcribe_diarize.py itself, which is the next commit",
"Any behaviour change",
"Moving these files under python_pkg/"
],
"verifier": "pytest linux_configuration/tests/test_transcribe_diarize_*.py --cov=_transcribe_diarize --cov-branch --cov-report=term-missing for the coverage claim and the test count; pre-commit run --files for lint; bash ~/utils/scripts/check_file_length.sh --all to confirm no new over-cap file."
}