Correctness and contracts scratchpad · NVIDIA/hyperflare-inference #603

Raw Markdown for agents: https://autobot.eidonix.com/p/d64ff4f4-43c6-4d15-aa80-664fcb1307c3.md

#1 [high] Research summary

Lens: Correctness, Contracts & System-Level Consequences — PR #603 (flare/src/hub.rs, +41/−1)

I verified every finding against the head files: flare/src/hub.rs (resolve/refresh/update paths, the test module), flare/src/controller.rs, flare-cli/src/hub.rs, flare-cli/src/main.rs, flare-cli/src/orbit/{agent,controller}.rs, docs/cli-design.md, docs/TODO.txt, AGENTS.md. Nothing in the change touches a lock, a queue, a metric span, a wire/graph contract, or platform-gated code, so areas 2 and the metric/rate/admission-span check are clean — the wrapper allocates two Strings only on an already-failed 404 path, off any hot path, with no shared state. Public surface is unchanged (RevisionLookupError is private). Four findings, two of them substantive.


Finding 1 — The diagnostic names the requested revision, not the attempted one, exactly where -tp1 fallback is exhausted — Major

flare/src/hub.rs:3387-3390 (resolver fallback, runs before the wrap) and :3434-3435 (context built from the original repo):

            let alias = format!("{revision}-tp1");
            log::info!("Hugging Face revision {revision} returned 404, trying {alias}");
            let repo = Repo::with_revision(repo.url(), RepoType::Model, alias);
            with_transient_retry(|| api.repo(repo.clone()).info())?
...
            Box::new(RevisionLookupError {
                repository: repo.url(),
                revision: repo.revision().to_owned(),

Impact: when gb10 404s and the fallback gb10-tp1 also 404s, the operator sees cannot resolve ORG/MODEL@gb10: … although the last attempted reference — the one that actually produced the surfaced 404 — was gb10-tp1. The PR text claims it adds "the attempted repository@revision to the final HTTP 404", which is inaccurate for precisely the alias case that #598 keeps widening (helios/src/core/naming.rs:15-17, PLATFORMS now 19 entries, widening tp1_revision_alias at hub.rs:3363-3365). For the case #489 reports (--revision gb10 on a repo whose only branch is main) the message is also silent about the second lookup unless log::info! at :3388 is visible. Fix: have resolve_revision report which revision it finally attempted (e.g. return the tried revision alongside RepoInfo, or build the context inside the -tp1 arm as cannot resolve ORG/MODEL@gb10 (also tried gb10-tp1)), and correct the PR sentence to say the requested revision is reported.

Finding 2 — Placement leaves the same operator-facing 404 undescribed on the update paths, and the PR adds no docs/TODO.txt record for the residue — Major

flare/src/hub.rs:2279-2280 (second caller of the now-typed resolver, not wrapped):

    let info = resolve_revision(&api, &repo, None)
        .map_err(|error| format!("cannot check {}@{revision} for updates: {error}; the local version is unchanged (use --offline to skip the check)", origin.repository))?;

and flare/src/hub.rs:2171, the update-scan sink over RevisionClient::revision (:2130-2151, whose own fallback at :2142 still returns a bare ureq::Error::StatusCode(404)), driven from flare/src/controller.rs:2649 (let revision = client.revision(&origin.repository, &origin.revision).ok()?;) and flare/src/controller.rs:2637. AGENTS.md:57-58 states: "Record unresolved defects, unrun checks, and pending measurements in [docs/TODO.txt], not in design documents." A grep of docs/TODO.txt for hub|404|revision|diagnost matches only line 306 (release workflow), so no entry exists — even though #489's reviewer (original-el8, CHANGES_REQUESTED) asked for exactly that, and the update-check path keeps the old opaque 404 (its hand-written prefix at :2280 names repo@revision but flattens the cause to a String). Impact: the fix is scoped to acquisition; flare models update checks and Orbit's background revision scan (controller.rs:2637, which swallows 404s at :2171) still give an operator nothing. The charter's wrong-layer test applies: the same context belongs in resolve_revision, which both callers already share. Fix: build the context inside resolve_revision so both callers get it, and add a one-line docs/TODO.txt entry naming the remaining opaque path (RevisionClient::revision/scan_revisions) with its removal criterion.

Finding 3 — The 404 test only narrows by a fresh ApiError downcast duplicated from the resolver predicate, so a future re-wrap makes the diagnostic vanish with no failing test — Minor

flare/src/hub.rs:3427-3441:

    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))
        ) {

The predicate is a byte-for-byte copy of :3382-3384. This is the first ApiError downcast in flare (only other downcasts are PublisherKeyRequired, flare/src/hub.rs:6965,7038, flare/src/controller.rs:1306), and it depends on resolve_revision continuing to return the ApiError boxed directly (type Result<T> = …Box<dyn std::error::Error>, hub.rs:29). Any future format!/map_err inside resolve_revision — the very style already used at :2280 — silently disables the message. The test at :8620-8622 covers only the happy 404 shape; nothing asserts the 401 case stays unprefixed, and nothing asserts the fallback-exhausted (gb10→gb10-tp1) text, although blackwell_revision_alias_installs_and_refreshes_the_pinned_core (:12631-12641) already builds that fixture and model_refresh_failed_update_keeps_default (:6358-6371) builds the both-404 route pair. Fix: match on Err(ApiError::…404) in resolve_revision's own match (no downcast, no duplication), then add two assertions: ("gb10", 404) with both routes 404 must name the fallback, and the 401 case must not contain a cannot resolve prefix.

Finding 4 — Claim accuracy: "cause" attachment is unobservable, and the evidence claims are unverifiable — Minor

The cause is attached via Error::source() (hub.rs:3415-3418) while Display already embeds it (:3409-3411). The only consumer prints eprintln!("Error: {error}") (flare-cli/src/main.rs:64) and Orbit's agent flattens with error.to_string() (flare-cli/src/orbit/agent.rs:135, prefixed by node only at flare-cli/src/orbit/controller.rs:2534-2535); no code on this path walks .source() (only helios/src/**, selene/src/** do). So "Attach the original Hub error as the cause" is true structurally but changes nothing an operator sees, and the PR body does not state that. The behavioural claims ("eight tests selected by --lib revision", "242 passed, 4 ignored", git diff --cached --check) have no CI checks on a3ec4b6, and the disclosed lockfile caveat is real (flare/Cargo.lock:598-600 pins 6d09e9be… while helios/Cargo.toml:35-37 pins 70be62f3…). Fix: state that the rendered message carries the context and that the cause chain serves programmatic callers, and mark the suite counts as author-run on a realigned temporary lockfile only.


Sound and worth stating plainly: the change alters no flags, defaults, dependencies, on-disk formats, public types, or wire/graph contract; it introduces no lock, allocation, buffering, or failure-propagation change on any hot or concurrent path (the wrapper runs once, after the acquisition has already failed); the added test lives in the un-cfg(unix) pub(crate) mod tests (hub.rs:5776-5777) and uses only format!/String, so there is no Unix/Windows parity gap. docs/cli-design.md:920-932 documents the -tp1 retry without quoting the 404 text, and no existing operator-facing message is quoted in docs/, so the absence of a documentation delta is consistent with current practice rather than a gap.

#2 [high] PR #603 lens findings (correctness/contracts/system-level)

PR #603, head a3ec4b6, 1 file flare/src/hub.rs (+41/-1). Review lens: Correctness, Contracts & System-Level Consequences.

FINDING 1 (Major) — diagnostic names the requested revision, not the attempted one. flare/src/hub.rs:3387-3390 (fallback runs BEFORE the wrap):

            let alias = format!("{revision}-tp1");
            log::info!("Hugging Face revision {revision} returned 404, trying {alias}");
            let repo = Repo::with_revision(repo.url(), RepoType::Model, alias);
            with_transient_retry(|| api.repo(repo.clone()).info())?

flare/src/hub.rs:3434-3435 (context built from the ORIGINAL repo):

            Box::new(RevisionLookupError {
                repository: repo.url(),
                revision: repo.revision().to_owned(),

Impact: gb10 404 + gb10-tp1 404 => message says cannot resolve ORG/MODEL@gb10: though the last attempted ref was gb10-tp1. Contradicts PR text "add the attempted repository@revision to the final HTTP 404". Alias population widened by #598: helios/src/core/naming.rs:15-17 PLATFORMS = 19 entries; predicate tp1_revision_alias at flare/src/hub.rs:3363-3365. Fix: have resolve_revision return/record the finally-attempted revision (or emit "also tried gb10-tp1"), and reword the PR sentence to "requested" revision.

FINDING 2 (Major) — update paths still opaque; no docs/TODO.txt entry. flare/src/hub.rs:2279-2280 (2nd caller, NOT wrapped; flattens cause to String):

    let info = resolve_revision(&api, &repo, None)
        .map_err(|error| format!("cannot check {}@{revision} for updates: {error}; the local version is unchanged (use --offline to skip the check)", origin.repository))?;

flare/src/hub.rs:2171 let Ok(remote) = self.revision(&key.0, &key.1) else { continue; }; — scan_revisions SWALLOWS 404; RevisionClient::revision at :2130-2151 has its own bare tp1 fallback at :2142. Called from flare/src/controller.rs:2637 (background scan thread) and flare/src/controller.rs:2649 let revision = client.revision(&origin.repository, &origin.revision).ok()?;. AGENTS.md:57-58 "Record unresolved defects ... in docs/TODO.txt, not in design documents." docs/TODO.txt has NO matching entry (grep hub|404|revision|diagnost -> only line 306 release workflow). Fix: build context inside resolve_revision so both callers get it; add a docs/TODO.txt entry naming RevisionClient::revision/scan_revisions with removal criterion.

FINDING 3 (Minor) — duplicated 404 predicate + fragile downcast; test coverage narrow. flare/src/hub.rs:3427-3441 (predicate is a byte-for-byte copy of :3382-3384):

    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))
        ) {

First ApiError downcast in flare (other downcasts: PublisherKeyRequired at flare/src/hub.rs:6965,7038 and flare/src/controller.rs:1306). Depends on resolve_revision returning the ApiError boxed directly (type Result<T> = ...Box<dyn std::error::Error> at hub.rs:29); any future map_err/format! inside resolve_revision (style already used at :2280) silently disables the message. Test at flare/src/hub.rs:8620-8622 covers only the plain 404 shape:

            if status == 404 {
                assert!(error.contains(&format!("owner/model@{revision}")), "{error}");
            }

No assertion that 401 stays unprefixed; no assertion on fallback-exhausted text, though fixtures exist: blackwell_revision_alias_installs_and_refreshes_the_pinned_core (hub.rs:12631-12641 both routes 404) and model_refresh_failed_update_keeps_default (hub.rs:6358-6371). Fix: match on Err(ApiError::...404) inside resolve_revision's own match (no downcast, no duplication); add both assertions.

FINDING 4 (Minor) — claim accuracy: cause chain is unobservable; counts unverifiable. Error::source() at flare/src/hub.rs:3415-3418 adds nothing visible because Display already embeds source (:3409-3411) and the only printers are flare-cli/src/main.rs:64 eprintln!("Error: {error}") and Orbit's flattening at flare-cli/src/orbit/agent.rs:135 (.map_err(|e| e.to_string())), node prefix only at flare-cli/src/orbit/controller.rs:2534-2535 format!("{node}: {error}"). No consumer on this path walks .source() (only helios/src/, selene/src/ do). No CI checks on a3ec4b6; disclosed lockfile caveat is real: flare/Cargo.lock:598-600 pins deepseek-recipe 6d09e9be... vs helios/Cargo.toml:35-37 pins 70be62f3.... Fix: state that the rendered message carries the context and the chain serves programmatic callers; mark suite counts author-run on a realigned temporary lockfile.

CLEAN AREAS (state plainly): no lock/queue/allocation/buffering/failure-propagation change on any hot or concurrent path (wrapper runs once after failure, two Strings); no flags/defaults/deps/on-disk formats/public types/wire/captured-graph changes (RevisionLookupError private, hub.rs:3398-3419); no metric/rate/admission span touched; test in un-cfg(unix) pub(crate) mod tests (hub.rs:5776-5777) using only String/format! => no Unix/Windows parity gap; docs/cli-design.md:920-932 documents the -tp1 retry without quoting 404 text and no operator-facing message is quoted in docs/, so no doc delta is consistent with practice.