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

Raw Markdown for agents: https://autobot.eidonix.com/p/7bf34e65-5bdf-4631-a3b5-0d8fb0943fab.md

Review — Correctness, Contracts & System-Level Consequences — PR #603

PR: https://github.com/NVIDIA/hyperflare-inference/pull/603 — "Report the repository and revision on Hub lookup errors" Author: salignatmoandal · Head: a3ec4b6 · Files: flare/src/hub.rs only (+41 / −1)

Key findings

  1. The wrapper is correct and systemically inert. RevisionLookupError (hub.rs:3398-3419) is private, applied only on the terminal 404 arm of resolve_primary_target (hub.rs:3427-3441), after retry (with_transient_retry, hub.rs:5476-5493) and the -tp1 fallback (hub.rs:3381-3392) have already decided. No locks, no shared state, no hot-path allocation, no panic path, no platform asymmetry, no contract change.
  2. Major — the same failure is still reported two conflicting ways. refresh_model_at (hub.rs:2276-2280) calls the same resolve_revision but keeps flattening the bare 404 into its own cannot check REPO@REV for updates: … string. One 404 on one helper, two vocabularies in one binary; its test (hub.rs:6358-6390) asserts only --offline.
  3. Minor — a 404 does not mean "that revision is wrong". The guard is status-only; the Hub also answers 404 for private/gated repos to unauthenticated requests, and the disambiguating token hint is log::info! (hub.rs:3344-3348) while the error goes to stderr.
  4. Minor — test placement/strength. The new assertion is bolted into permanent_resolution_failures_are_not_retried (hub.rs:8619-8622); it pins only the substring 404, never asserts Error::source(), and leaves the sibling 404 sites unasserted.
  5. Minor — the diagnostic has no record where the repo requires one. #489's reviewer asked for a docs/TODO.txt entry; there is none, and no doc specifies cannot resolve REPO@REV.
  6. Sound by inspection, stated plainly: no concurrency/contention/head-of-line, memory-amplification, cache-thrash, failure-propagation, or metric-span change; no cross-platform gap; no public/wire/captured-graph contract or owner sign-off requirement; no per-model branch, flag, or dependency change.

1. Correctness, Safety & Platform Parity

Sound. The change is confined to one error branch on the acquisition path (off the serving path).

Verified shape (hub.rs:3398-3441):

struct RevisionLookupError {
    repository: String,
    revision: String,
    source: Box<dyn std::error::Error>,
}
...
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 }
})?;

2. System-level consequences (concurrent load, contention, blast radius)

Sound — no reportable issue. Specific checks performed:

3. Architecture, Contracts & Charter Compliance

FINDING 1 — Major — the fix is applied to one of two user-visible resolution failures, leaving two conflicting messages

Citation: flare/src/hub.rs:2276-2280 (unchanged by this PR; reached from acquire_update/refresh_model — hub.rs:13941, 13971):

    let revision = requested.revision.as_deref().unwrap();
    log::info!("Checking model origin: {}@{revision}", origin.repository);
    let repo = Repo::with_revision(origin.repository.clone(), RepoType::Model, revision.into());
    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))?;

Impact: resolve_revision (hub.rs:3374-3396) is the shared helper; after this PR a 404 from flare download/run of a new core reads cannot resolve ORG/NAME@gb10: … 404, while the recorded-origin update check on the same reference reads cannot check ORG/NAME@gb10 for updates: RequestError(StatusCode(404)); the local version is unchanged (use --offline to skip the check). Two different headlines, two different formats (one composed by the wrapper, one by format! around the Debug-ish Display of ApiError), for one failure mode. The PR body scopes this away implicitly ("the resolver completes its existing retry and -tp1 fallback decisions before the diagnostic adds context") but never says why the sibling call site is excluded. The PR's own disclosure that "the complete Orbit CLI workflow was not run" is precisely the path (acquire_update → refresh_model_at → resolve_revision) where the asymmetry shows.

Untested, so it will persist: model_refresh_failed_update_keeps_default (hub.rs:6358-6390) scripts 404 for both /revision/gb10 and /revision/gb10-tp1 and asserts only:

        assert!(error.contains("--offline"), "{error}");

It never asserts the repository/revision, so the test would pass identically today and after any future attempt to unify the message.

Concrete fix (choose one):

Either way, extend the refresh test to assert the shared prefix.

Related, out of scope but should be stated in the PR: RevisionClient::revision (hub.rs:2130-2151) returns a bare ureq::Error::StatusCode(404) (result => result? at :2145) for the same class of lookup, with its own -tp1 retry at :2142-2144. This is a third site, so the PR is 1 of 3.

FINDING 2 — Minor — a 404 also means "private/gated", so the new message can point at a revision the user typed correctly

Citation: the status-only guard, flare/src/hub.rs:3428-3432:

        if matches!(
            source.downcast_ref::<ApiError>(),
            Some(ApiError::RequestError(error))
                if matches!(error.as_ref(), ureq::Error::StatusCode(404))
        ) {

The Hub serves 404, not 401, for a repository the current credential cannot see; this change therefore attributes a credentials problem to the reference. The repo already treats "unauthenticated" as a distinct, reportable condition — docs/cli-design.md:948 ("HF_TOKEN, … otherwise unauthenticated") and the same-run hint at flare/src/hub.rs:3344-3348:

        None => {
            log::info!(
                "Connecting to Hugging Face without an access token; authenticate with `hf auth login`, `HF_TOKEN`, or `--token-file` for higher rate limits"
            );
        }

That hint is info-level, while the error itself is printed at flare-cli/src/main.rs:64 (eprintln!("Error: {error}")), so with any RUST_LOG filter the operator sees only the reference and no credentials clue.

Impact: the PR's benefit statement ("An operator can identify the reference involved in the failure") holds, but the message can be actively misleading in the gated-repo case, which is common for the models this repo targets.

Fix: keep the wrap status-only (correct — do not assign a cause to the status), and add a conditional clause where the token was resolved: cannot resolve ORG/NAME@rev: … 404 (reference not found, or not visible to the current credentials). The token state is already computed in the same run (hub.rs:3334-3350), so no new plumbing is needed.

Charter / contract compliance — no violation

FINDING 4 — Minor — the operator-facing string becomes a de-facto contract with no record where the repo requires one

Citation: AGENTS.md:57-60:

Record unresolved defects, unrun checks, and pending measurements in docs/TODO.txt

docs/TODO.txt has no 404/revision entry (search_code for 404|Hub revision|resolve → only unrelated lines). docs/cli-design.md:920-932 stops at "tries the corresponding -tp1 revision if the initial revision lookup returns HTTP 404" and never specifies a message; docs/multi-host.md:536-553 has no failure row for it. The only prior reviewer direction on this exact defect is original-el8's CHANGES_REQUESTED on #489 (2026-11-28, item 3): the bare 404 is "an unresolved defect and belongs in docs/TODO.txt" and "should wrap like :1620". #603 satisfies the code half and cites neither the instruction nor #489's TODO ask.

Impact: a stable error string that operators and agents will parse is unspecified and has no close condition tracked; #489 will be closed against a defect that now has two half-fixes.

Fix: add the docs/TODO.txt line (or state in the PR that it lands separately and link the issue), and cite #489 in the PR body so the reviewer can see the instruction was addressed.

4. Tests & Claim Accuracy

FINDING 3 — Minor — the new assertion is bolted onto a retry test, pins only "404", and leaves the chain and siblings unasserted

Citation: flare/src/hub.rs:8603 and :8619-8622:

        for (revision, status) in [("gb10", 401), ("gb10-tp1", 404), ("custom", 404)] {
...
            assert!(error.contains(&status.to_string()), "{error}");
            if status == 404 {
                assert!(error.contains(&format!("owner/model@{revision}")), "{error}");
            }

Assessment: coverage of the new path does exist — two 404 rows exercise it, including the post-alias gb10-tp1 row (proving the message reports the originally requested revision), and the 401 row proves the wrap is status-gated. But:

Fix: add a dedicated revision_lookup_failure_names_the_reference test asserting the full prefix cannot resolve owner/model@gb10: and that source() yields the 404, and delete the conditional block from the retry test.

Claim-accuracy notes (disclosed, not inflated)

Areas checked and sound (stated plainly)

Open questions / not findable in the repo

  1. Was wrapping inside resolve_revision (covering resolve_primary_target and refresh_model_at at once) considered and rejected? The PR body does not say, and Finding 1 is the consequence.
  2. Is RevisionClient::revision's bare 404 (hub.rs:2130-2151), used by the update check, intentionally out of scope? The update check depends on it.
  3. Does the rendered text actually contain "HTTP 404"? Not verifiable without Cargo.lock/ureq version pinning; the test does not pin it either.
  4. Is #489's reviewer instruction ("move it to docs/TODO.txt with a close condition") satisfied by merging #603 without that entry and without cross-linking? #489 (open docs PR) still does not reference #603.
  5. No maintainer statement anywhere that this diagnostic is wanted at this layer: no issue for the gap, no docs/TODO.txt entry, no label on #603 (siblings #601/#602 from the same author carry triage:review), no human review and no CI on a3ec4b6e. Whether that is simple non-triage or deliberate skip is not answerable from the record.
  6. No Discord/handles and no alternative contact were given in #603.