testsAndMisc/docs/superpowers/contracts/transcribe-diarize-split-2026-08-17.json
Krzysztof kuhy Rudnicki dbf2f29b00 _transcribe_diarize: split 356 -> 164 + 143 + 105
The last Python file over the cap:

  _transcribe_media.py    143  _try_import, both duration probes,
                               get_media_duration, ffmpeg transcode, cleanup
  _transcribe_cluster.py  105  _resample_linear, _kmeans_cosine and its
                               iteration loop
  _transcribe_diarize.py  164  the pipeline: audio loading, the classifier,
                               embedding extraction, diarize_segments

The graph is a tree: _transcribe_media imports nothing local, _cluster takes
only _try_import from it, _diarize imports from both. All 13 top-level
definitions verified AST-identical to HEAD, and an AST scan confirms the
three module constants travelled to the modules that use them.

transcribe_fw.py now imports get_media_duration from _transcribe_media
rather than through _transcribe_diarize. Ruff removed that re-export as
unused and broke the import; running the program is what caught it, and
naming the owning module is the correct fix under the no-barrels rule.

Verified: transcribe_fw.py /nonexistent.wav still exits 2 and --help exits
0; 63 tests pass at 100% line and branch on all three modules; 338 pass in
the directory. Over-cap files 33 -> 32, and no Python file is over the cap
any more - the remaining 32 are 29 shell, 2 kotlin, 1 dart.

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

19 lines
1.3 KiB
JSON

{
"title": "Split _transcribe_diarize.py 356 -> 164 + 143 + 105",
"objective": "_transcribe_diarize.py was the last Python file over the 250-line cap. Now that it sits at 100% line and branch coverage, split it three ways along its natural seams: media probing, clustering maths, and the diarization pipeline itself. Code moves verbatim; the tests predate the seam and are re-pointed, not rewritten.",
"acceptance_criteria": [
"All three resulting modules are under 250 lines; the over-cap total falls 33 -> 32 and no Python file remains over the cap",
"All 13 top-level definitions are AST-identical to the pre-split file",
"The same 63 tests pass, with all three modules at 100% line and branch coverage",
"python3 transcribe_fw.py /nonexistent.wav still exits 2, the code transcribe.sh branches on",
"Import sites name the owning module - no re-export barrels",
"No suppression of any kind"
],
"out_of_scope": [
"Any behaviour change",
"The 29 over-cap shell scripts, which are the remaining work",
"Moving anything under python_pkg/"
],
"verifier": "A throwaway ast.dump identity check against HEAD; pytest with --cov of all three modules --cov-branch; running transcribe_fw.py and reading $? directly; pre-commit run --files; bash ~/utils/scripts/check_file_length.sh --all."
}