V1 Polish: common.py refactor, signs/layer bug fixes, repair context, test coverage #1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/v1-polish"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Implements the V1 Polish spec (
specs/v1-polish/) — the highest-leverage fixes distilledfrom the two-pass code review (
REVIEW.md). Four phases, executed and reviewed unit-by-unit:common.pyabsorbs the 8 duplicated helpers + stamp helpers;the 6 consumer modules now import from it instead of redefining (killing latent drift).
VIDEO_EXTSharmonized to(.mkv, .mp4, .m4v)everywhere. Added[project]deps topyproject.toml, a GitHub Actions CI workflow, and opportunisticmux.identify()caching.beam_sizeis now theWHISPER_BEAM_SIZEenv var (default 7, was hardcoded 5) withbest_of=beam_size.keep_event()no longer silently drops ASS drawing(
\p,\clip,\iclip) and animation (\t,\fade) sign events.build()normalizes layers sodub dialogue sits on layer 0 and every sign is shifted to
old_layer + 1— since higher ASSlayer = drawn on top, signs now render above dialogue while inter-sign z-order is preserved.
repair.build_prompt()gains optionalprev_text/next_textdialogue context(backward-compatible);
process()feeds the true full-transcript neighbors;is_target()fencepost fixed (
>= NSP_MAX→> NSP_MAX, so a card at exactly 0.5 nsp is treated as speech).needs_work()7-case matrix +a
process()ffprobe-backstop test,keep_event/layer matrix,mine_text().Notable decisions
layer = on top"; the libass ASS File Format Guide
is explicit that a higher layer is drawn over a lower one. The fix shifts signs up rather than
flattening them to a constant, preserving intentional multi-layer sign compositions.
common.pyowns the stamp helpers, notmux.py— sogenerate.pycan read stamps withoutimporting all of
mux(argparse/subprocess/mkvmerge). Pure code move, behavior-preserving.out_forunified on the dir-creating variant (safe superset);eng_sub_streamsunified oncodec_name in ("ass","ssa")(correct for both consumers)..m4vwalk-filter fix folded in (final-review recommendation):generate.py's--rootwalkhardcoded
(.mkv,.mp4), so.m4vepisodes were silently skipped by transcription whilemux.pyalready accepted them. Now usescommon.VIDEO_EXTS.Test plan
pytest -q→ 122 passed (was 107 at baseline; +15 new). Run via the venv; note this repo'sshell wraps commands with an output filter — use
rtk proxy python -m pytest tests/for raw output.ruff checkclean on all touched files (config: line-length 130, py39, select E/F/I/W/UP/B,ignore E701/E702). Whole-tree
ruff check .reports only 2 pre-existing errors inplex_refresh.py, which is out of V1 scope (deferred to the V2 ops spec, task B11) and leftuntouched.
.github/workflows/test.ymlinstallspysubs2 pytestand runspytest -q. Verified that themodule-scope
faster_whisperimport ingenerate.pydoes not break collection on a clean runner —it's imported only by
test_generate.py, which stubs it insys.modulesbeforeimport generate.Deferred (tracked for V2 / follow-up)
Non-blocking Minors from review, logged for a later pass: direct test of the
keep_eventunknown-plainfallthrough;
SKIP_IF_SRT=0env-toggle branch coverage; collapsing the residual locallog()defs ingenerate.py/repair.py;mux._IDENTIFY_CACHEis unbounded (memory only). The fullv2-models-opsspec (models/ops/remaining polish) is in
specs/v2-models-ops/.🤖 Generated with Claude Code
Declares runtime deps (pysubs2, faster-whisper) and dev extras (pytest, ruff) so the environment is reproducible. Two additions beyond the task's literal snippet, both required to actually satisfy its own "pip install -e .[dev] succeeds" criterion (verified in a disposable venv): - version = "0.1.0": setuptools' default backend rejects a [project] table without either `version` or `dynamic`. - [tool.setuptools] py-modules = []: this repo is a flat collection of top-level pipeline scripts (tests reach them via conftest.py's sys.path insert, not package imports), and setuptools' automatic package discovery otherwise errors out on multiple top-level directories (specs/, glossaries/) it can't classify.