Repository navigation
feat(pipeline): headless command and the slow end-to-end test - #13
Conversation
Turn translated text plus word times into readable cues that do not overlap and do not lose content silently, then write them as SRT. - CuePolicy carries the target profile's width, line, speed and duration numbers; the fit lane names no language and defaults only the two timing constants (120 ms split pause, 40 ms extension guard). - build_drafts takes every cue edge from word times, falls back to the source text when a translation is missing, and resolves an overlapping source span by pulling back the earlier end only. - The chain keeps a fitting cue, splits inside a real pause when both halves stand alone, extends into the silence before the next cue, condenses once through an injected hook (rejected if a digit or glossary term is lost), and trims last, logging the before and after lengths. - fit_cues renumbers cues from one in time order and remaps every adjustment to the surviving cue id. - The writer renders HH:MM:SS,mmm with unbounded hours, checks order and overlap before touching the target, writes through a same-directory temp file, refuses an existing file without the flag, and keeps the old file as .bak when overwritten, restoring it if the final rename fails. - 54 tests, including a strict SRT reader, a 100 hour cue, and a simulated rename failure.
Language rules and cue numbers live in TOML files, and the prompt that carries them is built in one place. - ko.toml and en.toml follow the design shape: identity, role fragments and the five cue numbers, with the English no-em-dash rule in en.toml rather than the base text. - profile.py validates every file with pydantic, refuses a pair that lacks either file, and refuses a source without source_rules or a target without target_rules so no rule is dropped silently. - prompt.py composes base rules, source fragment, target fragment, context, glossary and previous lines in that fixed order, omitting empty optional sections and capping previous lines at three.
Twenty cues per request, an answer keyed by the string form of the segment id, and a retry that hands the validator's own complaint back to the model. - translate.py chunks the segment list without touching ids, rejects a repeated id, validates every answer against the exact id set with a pydantic model (missing, extra, renumbered, non-canonical, non-string and blank values all named), retries once with that message in the request, then asks for each unresolved id alone. - A line that still cannot be translated keeps its source text and carries an "untranslated" QA flag; the chunk is recorded with its ids and error, and the job continues to the next chunk. - translated.json is rewritten atomically after every chunk, with the chunk index and attempt that produced each line. - openai_client.py speaks the chat-completions shape against a caller-chosen base URL through a ChatClient seam, always asking for json_object; an answer that is not a JSON object is a rejection so the retry carries the parser's complaint, while an unreachable endpoint is a request failure retried without a correction. - 38 tests, no network: a scripted chat client and a stub SDK factory cover the client, and tests/fakes.FakeTranslator covers the chunk, retry and fallback paths.
Adds the stages the chain needed and the command that runs them: - transcribe: faster-whisper behind the Transcriber protocol, device resolved from CTranslate2 (cuda when present, else cpu int8), word times in whole milliseconds with the segment widened to cover every word. - glossary: pass-one candidates (quoted strings, mid-sentence names, a name repeated at a line start), written with a header, loaded and extended rather than replaced, and used as hotwords for the second pass. - output: qa.json measured from the cues and words (overlap, cue-to-word delta, trims, condenses, glossary audit, energy onset) plus the retained segments.json and cues.json. - run: probe, extract, transcribe twice, glossary, translate, fit, write, with the container offset applied at write time only and a named failure when recognition returns nothing. - cli: `subsmith-headless job.json`, endpoint from three environment variables, exit 0/1/2 split the way the check script splits them. The one slow test builds a 30 second mp4 with espeak-ng and ffmpeg, runs the tiny model twice on CPU, and translates against a canned id-faithful translator. It resolves the cached weights with local_files_only=True, so a miss fails by name instead of reaching the network. faster-whisper 1.2.1 calls av.open(metadata_errors=...), which av 19 removed; the dependency carries av<19 until faster-whisper's own floor moves.
The workflow installs espeak-ng (the slow fixture's speech), caches the Hugging Face hub, provisions the tiny weights before the gate, and runs `pytest -q -m slow tests/pipeline/test_e2e.py` after `make check` so the CPU-only path is proven on every pull request.
The first run of the check workflow sat in `apt-get` for more than fifteen minutes with no step update, which occupies the job until GitHub's own timeout and tells us nothing. A twelve minute cap turns that into a visible failure the next attempt can be judged on.
Marking the suite `-m 'not slow'` by default moves the six real-ffmpeg ingest integration tests out of `make check` along with the new end-to-end test. The slow step now runs `-m slow tests`, so both stay covered in CI and the default gate stays free of ffmpeg and model work.
Master's #8 rewrote the languages lane, so the add/add conflicts in languages/__init__.py, languages/profile.py, pipeline/prompt.py and their tests resolve to master's versions; this branch's earlier language implementation is superseded and the flat en.toml/ko.toml copies are removed. The translation code is kept. openai_client.py now compares the request language against profile.tag instead of the removed profile.code. make check passes.
…ne-e2e The base now carries master's rewritten languages lane, so the add/add conflicts in cues.py, srt.py and their tests resolve to the base's versions. The headless chain is kept and ported to the new profile API: run.py compares against profile.tag, uses profile.whisper, and supplies MAX_DIALOGUE_LINES as the policy's screen rule. make check passes.
|
Applied the same test standard on this branch, after merging the trimmed base and the cleanup branch.
285 tests, |
|
Review items implemented; the glossary candidate mechanism (items 4 and 5) is held for the benchmark. Changed
Merge Gate, run on forge in the branch worktree CI run 47481252120 on Held |
Replace extract_candidates with a TermNominator seam. One call after pass one returns a headword, an English rendering and a kind per term; merge_glossary keeps only terms that occur literally in the pass-one text, normalises to NFC, deduplicates and caps the new rows. A failed nomination leaves the job valid and records the error in qa.json. The translation prompt now says a glossary row is a stem, so the source language's honorifics stay attached.
|
The glossary benchmark is in, and the rule path is replaced with endpoint nomination. Benchmark (forge, 38:00-43:00 of the Jihyo episode, 105 segments, large-v3 CPU)
Implemented
Gate Slow suite on forge: 7 passed. CI run 47486582208 on The benchmark's caveat: the 8-3 preference is real, but half the batches were judged by the translator model, and most cited reasons are general fidelity rather than terminology. The mechanism is the right one for Korean; the measured consistency benefit is small with this translator. |
The glossary block no longer carries an honorific policy. It says an entry is a stem and the source and target profile rules decide how it appears in a line. The nomination prompt asks for the dictionary form, not an inflected form. Korean keeps its -ssi/-nim rule in ko.toml; no new profile field and no language list in the pipeline. The spec also states that v1 has one glossary per job, with no shared or series-level file.
|
Follow-up: glossary policy now lives in the language profiles.
Gate on forge: 343 passed, 7 deselected. CI run 47489116187 on |
Hermes PR ReviewReviewed commit: Review status: No actionable findings Executive summaryPR 13 makes the headless path real. Pass 1 found two issues: a Medium where the job snapshot could rewrite the caller's This is not an approval; the merge decision is the human's. FindingsNo actionable findings. The two pass-1 findings are fixed and verified below. Previously reported findings
PR-001 fix: PR-002 fix: the CLI catches Verification
Implementation walkthroughOverviewThe PR turns the headless path into a usable command. It adds Execution flow
Fix decisions
Assumptions and invariants
Changed files
Assumptions and risksPass 1 read the risk-first set completely: CI, dependency manifest, entry point, orchestration, persistence and external boundaries, with the remaining test modules and non-changed spec lanes listed as not examined in full. Pass 2 reviewed the fix diff and its interactions and did not hit the budget. The snapshot collision is resolved. The remaining limit is verification: Recommended human review order
|
The snapshot wrote job.to_dict(), including the CLI --overwrite switch, and overwrote the job file when the source lived inside the job directory. A later run then replaced the SRT and its backup without the flag. - Write the snapshot without the CLI-only overwrite field. - Skip the snapshot when it resolves to the CLI's source job file. - Translate SrtExistsError at the CLI boundary to "pass --overwrite". - Test the second run, the snapshot payload, and a source job inside job_dir.
What this lands
One command takes a video to an SRT with the real chain, and CI proves it on CPU.
subsmith-headless job.json(new console script,src/subsmith/cli.py) reads ajob.json(JobConfig), resolves the language pair from the shipped profiles, and runsprobe, extract, transcribe, glossary, translate, fit, write. Exit 0 finished, 1 the
pipeline refused the input, 2 the job description or endpoint settings are unusable,
each with the name in the message.
src/subsmith/pipeline/transcribe.py: faster-whisper behind theTranscriberprotocol. Device resolution asks CTranslate2 (cuda when a device answers, else cpu with
int8), word times become whole milliseconds, and a segment that misses one of its words
is widened instead of the word being clamped or dropped.
src/subsmith/pipeline/glossary.py: candidates from pass one (quoted strings,mid-sentence names, a name repeated at a line start, anything that also appears
lowercase is dropped as a sentence capital),
glossary.tsvwith a header, loaded andextended rather than replaced, used as hotwords for pass two.
src/subsmith/pipeline/output.py:qa.jsonmeasured from the finished cues andrecognized words (cue count, covered duration, average cps, longest line, overlaps,
max cue-to-word delta, trims, condenses, glossary audit, energy onset against the first
cue, device, model, offset, untranslated count, pass disagreements), plus
segments.jsonand
cues.json.src/subsmith/pipeline/run.py: the chain and its two cross-lane rules, the offsetapplied at write time only, and a named failure when recognition returns nothing.
tests/pipeline/test_e2e.py(markedslow): builds a 30 second mp4 with espeak-ng andffmpeg, runs the tiny model twice on CPU, and translates against a canned,
id-faithful translator. The weights are resolved with
local_files_only=True, so thetest fails by name instead of downloading.
after
make check, so the CPU path is proven on every pull request.make checknow selects-m 'not slow'; the slow suite is opt-in, exactly as the card'sacceptance command runs it, and CI runs
-m slow testsin its own step so the six ingestintegration tests that were previously in the default gate stay covered.
Evidence
The slow run itself:
device=cpu model=tiny segments=6 cues=6 wall=2.6s, six cues, zerooverlaps, zero trims,
first_speech_onset_ms0,max_cue_to_word_delta_ms0, and an SRTthat parses with sequential indices and non-overlapping times.
CI: run 47270137254 on
e820cf4is green end to end, includingpytest -q -m slow tests(7 passed: this test plus the ingest lane's six real-ffmpegintegration tests) and
make check(282 passed).Rulings
card/fit-cues(needed by the chain) and is based oncard/translate. It must be retargeted tomasteronce feat(pipeline): fit chain and atomic SRT writer #7, feat(languages): load profile pairs and compose the translation prompt #8 and feat(pipeline): chunk, validate and retry id-keyed translation #12 land.(
SUBSMITH_TRANSLATE_BASE_URL,SUBSMITH_TRANSLATE_API_KEY,SUBSMITH_TRANSLATE_MODEL) until the settings lane ships its TOML file. The jobsnapshot in
job.jsontherefore does not yet carry the endpoint.requested in this card; rows are written with an empty target and used as hotwords and
context only, which the lane allows. Filed as a follow-up card rather than invented
prompt text here.
fit_cuesacceptscondenser=None, so an over-longtranslation is split, extended, then trimmed with the trim logged. Same follow-up.
av<19: faster-whisper 1.2.1 callsav.open(..., metadata_errors=...), removed inav 19. A bound, not a pin.
en -> koprofile pair written into a temp directory, becausethe shipped files are role-specific (
kois a source,ena target). The fixture'sspeech is English because the box has no usable Korean synthesizer; the translation is
canned Korean.
AGENTS.mdcould not be updated from this run: the write to an agent-instruction filewaits for the owner's approval, so the headless command and the slow-test provisioning
live in the module and test docstrings until he lands that section.