#1 [high] Finding 1 (high): private RevisionLookupError struct + 2 trait impls is unreachable machinery; collapse to a 6-line map_err closure
PR #603, head a3ec4b6e, single changed file flare/src/hub.rs (+41/-1).
Deleted material: RevisionLookupError struct + Display + Error::source() at flare/src/hub.rs:3398-3419 (verbatim):
#[derive(Debug)]
struct RevisionLookupError {
repository: String,
revision: String,
source: Box<dyn std::error::Error>,
}
impl std::fmt::Display for RevisionLookupError {
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
formatter,
"cannot resolve {}@{}: {}",
self.repository, self.revision, self.source
)
}
}
impl std::error::Error for RevisionLookupError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
Some(self.source.as_ref())
}
}
Construction site, flare/src/hub.rs:3427-3441 (verbatim):
let info = resolve_revision(api, repo, progress).map_err(|source| {
if matches!(
source.downcast_ref::<ApiError>(),
Some(ApiError::RequestError(error))
if matches!(error.as_ref(), ureq::Error::StatusCode(404))
) {
Box::new(RevisionLookupError {
repository: repo.url(),
revision: repo.revision().to_owned(),
source,
})
} else {
source
}
})?;
Evidence it is dead plumbing: search_code RevisionLookupError in flare/ returns exactly four hits — :3399, :3405, :3415 (definition) and :3433 (sole construction). Nothing downcasts it; flare-cli never names it; no .source() / .chain() call exists anywhere in flare/ or flare-cli/src (search_code '\.source\(\)' in flare → no matches), so the Error::source() impl is never used. Display already interpolates self.source, so source() re-exports the same text a second time — two paths to one string.
Replacement (6 lines, no new type):
let info = resolve_revision(api, repo, progress).map_err(|error| {
if !hub_lookup_missing(&error) {
return error;
}
format!("cannot resolve {}@{}: {error}", repo.url(), repo.revision()).into()
})?;
Repo precedent in the same file: transport_hint at flare/src/hub.rs:5511-5521 does exactly this (if !content_failure(&text) { return error; }, then format!("{text}; ...").into()), and refresh_model_at at flare/src/hub.rs:2280 wraps the same resolve_revision failure with a one-line map_err(|error| format!("cannot check {}@{revision} for updates: ...")). So the file's established idiom is a format! in map_err, not a typed wrapper. A named variant (fn hub_404(repo: &Repo, error: Box<dyn Error>) -> Box<dyn Error> beside transport_hint) is equally fine and buys a /// doc-comment slot that neighbours :5457-5459 and :5508-5510 have and the new struct lacks.
Convention backing: AGENTS.md:188-193 rejects "unsupported abstractions ... speculative compatibility" and churn; a private typed error with no consumer qualifies. Contrast the file's other hand-written error struct PublisherKeyRequired (flare/src/hub.rs:31-47), which is pub precisely because flare-cli downcasts it (flare-cli/src/hub.rs:75 and :139).
Cost of not simplifying: two remaining resolution sites (refresh_model_at flare/src/hub.rs:2279-2280 and RevisionClient::revision flare/src/hub.rs:2130-2151) would each need a 23-line struct copy to get the same diagnostic, versus 2 lines with the closure/helper.
Test compatibility: the new assertion at flare/src/hub.rs:8620-8622 checks error.contains("owner/model@{revision}"); the replacement produces byte-identical text, so the test stands unchanged. Net deletion ≈ 30 lines with no behavior change.
#3 [high] Research summary
Reviewed PR #603 (Flare "Report the repository and revision on Hub lookup errors", head a3ec4b6e, one changed file flare/src/hub.rs, +41/-1) through the Subtraction/Simplicity/Conventions lens. Scratchpad entries 1 (high) and 2 (medium) hold the verbatim quotes and citations.
The diff is small and its intent is a one-line operator-facing diagnostic, but ~23 of the 41 added lines are a private typed-error wrapper that nothing consumes. Finding 1: delete RevisionLookupError and its Display/Error::source() impls at flare/src/hub.rs:3398-3419 and collapse the map_err at :3427-3441 to a 6-line closure (or one helper beside transport_hint at :5511-5521). Evidence: the type has exactly one construction site and zero readers (search_code → only :3399/:3405/:3415/:3433), no .source()/.chain() call exists anywhere in flare/ or flare-cli/src, and Display already interpolates the source string that Error::source() re-exports. The file's established idiom for this exact wrapper is format!(...).into() — see transport_hint (:5511-5521, same early-return-then-format shape) and refresh_model_at's cannot check {repo}@{revision} for updates: {error} at :2280; the file's only other hand-written error struct, PublisherKeyRequired (:31-47), is pub because flare-cli downcasts it. Test at :8620-8622 still passes unchanged since the text is byte-identical. AGENTS.md:188-193 (no unsupported abstractions/churn) is the convention hook.
Finding 2 (secondary, do not block): the new guard at :3431 is the third verbatim copy of matches!(error.as_ref(), ureq::Error::StatusCode(404)) in 1300 lines (:3383 and :2142), and the file already owns this classification in transient_hub_error (:5460-5472); one fn hub_not_found(&ureq::Error) predicate collapses both sites. Also noted: the new items carry no doc comment although both neighbouring helpers do, and AGENTS.md:43-50 requires the prose skill for code-produced text.
Everything else is lean: the test change is a 3-line conditional inside an existing loop, no flags/config/dead branches are added, and the resolver's retry and -tp1 fallback logic is untouched (the wrap happens after tp1_revision_alias at :3381-3392).
#2 [medium] Finding 2 (medium): PR adds a third verbatim copy of the StatusCode(404) test; file already names this classification in transient_hub_error
PR #603, flare/src/hub.rs.
The PR's new predicate at :3431 duplicates the guard 48 lines above at :3383 (unchanged by the PR), and a third occurrence exists at :2142:
- flare/src/hub.rs:3382-3384 (pre-existing):
Err(ApiError::RequestError(error))
if matches!(error.as_ref(), ureq::Error::StatusCode(404))
&& tp1_revision_alias(revision) =>
- flare/src/hub.rs:3428-3432 (added by the PR):
if matches!(
source.downcast_ref::<ApiError>(),
Some(ApiError::RequestError(error))
if matches!(error.as_ref(), ureq::Error::StatusCode(404))
) {
- flare/src/hub.rs:2141-2143 (pre-existing,
RevisionClient::revision):
let body = match get(revision) {
Err(ureq::Error::StatusCode(404)) if tp1_revision_alias(revision) => {
Simplification: one predicate next to the file's existing classifier transient_hub_error (flare/src/hub.rs:5460-5472, which already owns "which Hub errors are transient" and has a /// doc comment at :5457-5459):
/// Whether a Hub response means the reference does not exist.
fn hub_not_found(error: &ureq::Error) -> bool {
matches!(error, ureq::Error::StatusCode(404))
}
Then :3383 becomes if hub_not_found(&error) and the new site if hub_not_found(error.as_ref()), removing the duplicated 3-line matches! shape from a 40-line neighbourhood. Only worth doing together with Finding 1 (the closure is the bulk of the win); as a standalone change it is optional and should not block the PR.
Minor prose note (fold into Finding 1): the new items at flare/src/hub.rs:3398-3419 carry no doc comment, while both neighbouring helpers added by earlier commits do (transient_hub_error :5457-5459, transport_hint :5508-5510), and AGENTS.md:43-50 requires the repo prose skill for code-produced prose.
#4 [medium] Finding 3 (low): what this diff does NOT add — non-findings that keep the report honest
PR #603, flare/src/hub.rs, head a3ec4b6e, +41/-1.
Checked and found clean — the report should say so plainly rather than invent nitpicks:
-
No new knobs or branches. The whole production delta is one
map_errclosure plus a private struct. No flag, noHubOptionsfield (use crate::options::HubOptions;at :27 unchanged), no env read (would violate AGENTS.md:452-455 anyway), no fallback path.pr_diffis the full evidence: only two hunks, one at :3395-3441 and one test hunk at :8617-8622. -
No unused imports or dead code left behind.
ApiErrorwas already imported at flare/src/hub.rs:20 (sync::{Api, ApiBuilder, ApiError}) and already used at :3382 and :5460-5472, so the newdowncast_ref::<ApiError>()adds no import. Nothing became unused:resolve_revision(:3374) still has its other caller at :2279 (refresh_model_at) plus the internal call at :3390. -
Retry/fallback ordering is preserved, not duplicated. The wrap sits at :3427, i.e. after
with_transient_retry(:3381, :3390) and after thetp1_revision_alias404→-tp1retry (:3383-3391), so no retry logic is copied into the diagnostic. Consequence worth stating: the message names the originally requested revision (owner/model@gb10, not@gb10-tp1) becauserepois untouched — that is what the assertion at :8620-8622 checks via the loop value at :8603. -
Test addition is minimal and idiomatic. Exactly 3 added lines, guarded by the existing
if status == 404, inside the existingfor (revision, status) in [("gb10", 401), ("gb10-tp1", 404), ("custom", 404)]loop at flare/src/hub.rs:8603; the guard makes the 401 path provably exercised without the wrap, so both directions are covered by one loop iteration each. Not worth restructuring; theformat!("owner/model@{revision}")insidecontainsis fine. -
No duplication of an existing public abstraction. There is no repo helper that already builds "cannot resolve REPOSITORY@REVISION".
search_code 'cannot resolve'in flare/src yields only :3409 (the new one) plus two unrelated home-directory messages (:environment.rs:28, :trust.rs:191). The closest analogue ismissing_source(flare/src/hub.rs:2527-2544), which formats a cache-miss messagecore {repository}@{revision} ... is not available in the Flare cache; it is a different error class (no source error, different wording) and should not be reused.
Conclusion for the report: the only real subtraction is Finding 1 (~30 lines removable with identical text); Finding 2 is an optional one-line predicate; everything else in the diff is lean and idiomatic for this file.