Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
---
name: bug report
about: something broke, and you have the details
about: report a reproducible problem
title: ''
labels: bug
assignees: ''
---

what happened? say it in one sentence.
what happened?

what did you expect to happen instead?
what did you expect instead?

how do i reproduce it? a command line, a file, or a url is ideal. if it needs an
audio file, say what kind and roughly how long.
how can it be reproduced? include the exact command and a small input example
when possible. do not upload private recordings or credentials.

paste the exact error text if there is one.
paste the exact error output:

```text

Expand All @@ -22,9 +22,11 @@ paste the exact error text if there is one.
environment:

- scribe version (`scribe --version`):
- os and terminal:
- model (if relevant):

if it is an accuracy complaint rather than a crash, name the model first. nine
times out of ten the answer is "try large-v3-turbo", but i will read the report
anyway.
- operating system and architecture:
- terminal:
- model and language:
- input type and approximate duration:
- relevant `scribe --doctor` output:

for transcription-quality reports, include the model name and language, plus a
short description of what was wrong with the result.
13 changes: 6 additions & 7 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
---
name: feature request
about: an idea worth arguing about
about: propose a focused improvement
title: ''
labels: enhancement
assignees: ''
---

what is the actual problem you are trying to solve? not "add feature x" — the
thing that makes feature x worth writing.
what problem are you trying to solve?

what would you change?
what behaviour would you expect from scribe?

what did you try already?
what alternatives or workarounds have you tried?

anything that would make you reject this idea? if the answer is "it adds a 200
mb dependency for one flag", say so. i will probably agree.
are there compatibility, performance, privacy or maintenance trade-offs to
consider?
29 changes: 10 additions & 19 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,20 @@
---
name: pull request
about: changes for review
title: ''
labels: ''
assignees: ''
---

what does this change, in one sentence?
what does this change?

why is it needed? link the issue if there is one.

how did you verify it? paste the commands you actually ran, not the ones you
meant to run.
how did you verify it? include the commands you actually ran.

```sh

```

if this touches the worker, the download path, or the layout, explain the
trade-off you picked. those are the three places where the obvious fix is
usually the wrong one.
if this touches transcription workers, downloads, model caching, exports or
terminal rendering, explain the relevant failure mode and trade-off.

checklist (delete the ones that do not apply):
checklist:

- [ ] `cargo test` passes
- [ ] `cargo clippy --all-targets -- -D warnings` is clean
- [ ] `cargo fmt --all -- --check` is clean
- [ ] docs updated if behaviour changed
- [ ] `cargo fmt --all -- --check` passes
- [ ] `cargo clippy --locked --all-targets --all-features -- -D warnings` passes
- [ ] `cargo test --locked --all-targets --all-features` passes
- [ ] documentation is updated when behaviour changes
- [ ] no unrelated files or generated artifacts are included
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ run the diagnostic command for a read-only report:
scribe --doctor
```

it checks dependencies, model integrity, paths and permissions. it does not install packages or modify files.
it checks dependencies, model integrity and configured paths. it does not install packages or modify files, and it does not probe write permissions.

## performance and implementation

Expand Down
62 changes: 52 additions & 10 deletions src/doctor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,21 @@ struct Row {
detail: String,
}

fn cache_status(cache: &std::path::Path) -> (Verdict, &'static str) {
if cache.is_dir() {
(Verdict::Ok, "directory exists; write access not tested")
} else if cache.exists() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Doctor misses unusable cache

When the configured cache path is a dangling symlink and its parent directory exists, cache.exists() follows symlinks and returns false, so cache_status reports that the cache will be created; DownloadLock::acquire then fails when create_dir_all encounters the symlink, and the user sees a download error despite the doctor warning.

Detect an occupied dangling-symlink path without following it and report it as unusable instead of saying it will be created.

Also at src/doctor.rs:33-34.

Prompt for AI agents
In `src/doctor.rs` at line 31:

**Doctor misses unusable cache**

When the configured cache path is a dangling symlink and its parent directory exists, `cache.exists()` follows symlinks and returns false, so `cache_status` reports that the cache will be created; `DownloadLock::acquire` then fails when `create_dir_all` encounters the symlink, and the user sees a download error despite the doctor warning.

Detect an occupied dangling-symlink path without following it and report it as unusable instead of saying it will be created.

Also at `src/doctor.rs:33-34`.

(Verdict::Fail, "path exists but is not a directory")
} else if cache.parent().is_some_and(std::path::Path::is_dir) {
(
Verdict::Warn,
"will be created on first download; write access not tested",
)
} else {
(Verdict::Fail, "parent directory is missing")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Critical · Fresh cache reports failure

When the cache directory or one of its parent directories has not been created yet, cache_status returns Fail because it checks only the immediate parent, so scribe --doctor exits with status 1 for a cache tree that DownloadLock::acquire can create recursively; the regression test also fails because it expects Warn.

Treat a missing cache path as creatable when its directory tree can be created on first download, and return a warning instead of a failure.

Also at src/doctor.rs:37, src/doctor.rs:290-292.

Prompt for AI agents
In `src/doctor.rs` at line 36:

**Fresh cache reports failure**

When the cache directory or one of its parent directories has not been created yet, `cache_status` returns `Fail` because it checks only the immediate parent, so `scribe --doctor` exits with status 1 for a cache tree that `DownloadLock::acquire` can create recursively; the regression test also fails because it expects `Warn`.

Treat a missing cache path as creatable when its directory tree can be created on first download, and return a warning instead of a failure.

Also at `src/doctor.rs:37`, `src/doctor.rs:290-292`.

}
}

fn version(binary: &std::path::Path, args: &[&str]) -> Option<String> {
let output = std::process::Command::new(binary)
.args(args)
Expand Down Expand Up @@ -109,18 +124,11 @@ pub fn run(selected_model: Option<&str>) -> i32 {
});

let cache = model::cache_dir();
let cache_ok = cache
.parent()
.map(|p| p.is_dir())
.unwrap_or_else(|| cache.is_dir());
let (cache_verdict, cache_detail) = cache_status(&cache);
rows.push(Row {
label: "model cache",
verdict: if cache_ok { Verdict::Ok } else { Verdict::Fail },
detail: format!(
"{} ({})",
cache.display(),
if cache_ok { "writable" } else { "not writable" }
),
verdict: cache_verdict,
detail: format!("{} ({cache_detail})", cache.display()),
});

let chosen = selected_model.map(str::to_string).or_else(|| {
Expand Down Expand Up @@ -276,6 +284,40 @@ pub fn run(selected_model: Option<&str>) -> i32 {
mod tests {
use super::*;

#[test]
fn cache_status_does_not_claim_unchecked_write_access() {
let dir = std::env::temp_dir().join(format!("scribe-doctor-{}", std::process::id()));
let _ = std::fs::remove_dir_all(&dir);
std::fs::create_dir_all(&dir).unwrap();
let cache = dir.join("models");
assert_eq!(
cache_status(&cache),
(
Verdict::Warn,
"will be created on first download; write access not tested"
)
);
std::fs::create_dir_all(&cache).unwrap();
assert_eq!(
cache_status(&cache),
(Verdict::Ok, "directory exists; write access not tested")
);
std::fs::remove_dir_all(&dir).unwrap();
}

#[test]
fn cache_status_rejects_a_file_at_the_cache_path() {
let dir = std::env::temp_dir().join(format!("scribe-doctor-file-{}", std::process::id()));
std::fs::create_dir_all(&dir).unwrap();
let cache = dir.join("models");
std::fs::write(&cache, b"not a directory").unwrap();
assert_eq!(
cache_status(&cache),
(Verdict::Fail, "path exists but is not a directory")
);
std::fs::remove_dir_all(&dir).unwrap();
}

#[test]
fn verdict_labels_are_short() {
assert_eq!(Verdict::Ok.label(), "ok");
Expand Down
29 changes: 22 additions & 7 deletions src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,16 @@ pub fn validate_cached(info: &ModelInfo, path: &Path) -> Result<(), String> {

/// custom models have no authoritative checksum in the catalog. the least we
/// can do is reject empty stubs and files that cannot possibly be ggml models.
fn read_model_header(path: &Path) -> Result<[u8; 4], String> {
use std::io::Read;
let mut file =
File::open(path).map_err(|e| format!("cannot read model {}: {e}", path.display()))?;
let mut magic = [0u8; 4];
file.read_exact(&mut magic)
.map_err(|e| format!("cannot read model header {}: {e}", path.display()))?;
Ok(magic)
}

pub fn validate_custom(path: &Path) -> Result<(), String> {
let len = fs::metadata(path)
.map_err(|e| format!("cannot inspect {}: {e}", path.display()))?
Expand All @@ -506,13 +516,8 @@ pub fn validate_custom(path: &Path) -> Result<(), String> {
len
));
}
let mut magic = [0u8; 4];
use std::io::Read;
if let Ok(mut file) = File::open(path)
&& file.read_exact(&mut magic).is_ok()
&& &magic != b"ggml"
&& &magic != b"GGUF"
{
let magic = read_model_header(path)?;
if &magic != b"ggml" && &magic != b"GGUF" {
return Err(format!(
"{} does not look like a ggml model (bad header). refusing to hand it to whisper",
path.display()
Expand Down Expand Up @@ -1378,6 +1383,16 @@ mod tests {
fs::remove_dir_all(&dir).unwrap();
}

#[test]
fn custom_model_header_read_errors_are_rejected() {
let dir = std::env::temp_dir().join(format!("scribe-header-{}", std::process::id()));
fs::create_dir_all(&dir).unwrap();
let path = dir.join("truncated.bin");
fs::write(&path, b"gg").unwrap();
assert!(read_model_header(&path).is_err());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Validator rejection goes untested

When validate_custom is changed to ignore a header-read error, custom_model_header_read_errors_are_rejected asserts only that read_model_header returns an error, so it still passes if validate_custom stops propagating that error and accepts an unreadable header.

Exercise validate_custom with an input that passes the minimum-size check but produces a header-read error, and assert that validation rejects it.

Prompt for AI agents
In `src/model.rs` at line 1392:

**Validator rejection goes untested**

When `validate_custom` is changed to ignore a header-read error, `custom_model_header_read_errors_are_rejected` asserts only that `read_model_header` returns an error, so it still passes if `validate_custom` stops propagating that error and accepts an unreadable header.

Exercise `validate_custom` with an input that passes the minimum-size check but produces a header-read error, and assert that validation rejects it.

fs::remove_dir_all(&dir).unwrap();
}

#[test]
fn validate_custom_rejects_stubs_and_wrong_headers() {
let dir = std::env::temp_dir().join(format!("scribe-custom-{}", std::process::id()));
Expand Down