Skip to main content

Module diagnostics

Module diagnostics 

Source
Expand description

Per-take diagnostics written to disk, best-effort.

One take becomes one directory holding the original capture, every transcription stage, and the timings - so β€œwhich stage ate the words” is answerable by opening files rather than by rerunning the take under investigation. The layout is granular on purpose: the pre-normalization text is kept per window, because the joined form cannot show whether a window lost the words or the join did.

Everything here is best-effort: a capture that cannot be written is logged and dropped, never propagated, because diagnostics must never break a take.

Retention: the store keeps the last RETAINED_TAKES takes, pruning the oldest by directory name after each write.

Re-exportsΒ§

use std::path::Path; πŸ”’
use std::path::PathBuf; πŸ”’
use std::time::SystemTime; πŸ”’
use std::time::UNIX_EPOCH; πŸ”’
use serde_json::json; πŸ”’
use transcribe_cpp::CancelToken; πŸ”’
use crate::audio::SAMPLE_RATE; πŸ”’
use crate::config::ModelSpec; πŸ”’
use crate::engine::Stages; πŸ”’

StructsΒ§

TakeModels πŸ”’
The models a take ran under: the resolved specs the engine was built with.
TakeRecord πŸ”’
Everything one finished take contributes to the store.
WindowRecord πŸ”’
One window’s record: the slice of capture it covered and the raw pre-normalization text it produced.

ConstantsΒ§

RETAINED_TAKES πŸ”’
How many takes the store keeps, and the bench’s corpus along with it.

FunctionsΒ§

capture_take πŸ”’
Write one take into dir/take-<take_id>/ and prune the store to RETAINED_TAKES. Nothing here can fail the caller: every step logs its own failure and stops that take’s capture.
claim_take_dir πŸ”’
Claim dir/take-<stamp>/, advancing a millisecond per name already taken, and answer the name and the directory it claimed.
model_identity πŸ”’
One role’s resolved spec as meta.json names it: the file, the digest it declares where it declares one, and the size.
prune πŸ”’
Delete every take but the newest RETAINED_TAKES. Only store directories count - take- followed by nothing but digits - so a user directory that happens to share the prefix is never touched. Removal is best-effort, and a directory that will not leave is logged: it occupies a retention slot invisibly otherwise.
sha256_file πŸ”’
A file’s sha256, lowercase hex; empty when it cannot be read.
starts_take πŸ”’
A store directory: take- followed by all-ASCII digits. Anything else - take-2026-photos, a user’s own folder - is not ours to prune.
take_stamp πŸ”’
The unix-millisecond stamp a take directory is named by, as take-<13 digits>: sortable, and 13 digits holds until the year 2286 so lexicographic order never lies about recency.
write_take πŸ”’
One claimed take’s files, meta.json last, answering whether the take was written whole.
write_wav πŸ”’
Encode audio as a canonical 16-bit PCM wav at the one rate every model here reads.