Skip to content

Import via download: identify sources by bytes and ingest them as downloads - #190

Open
MrScripty wants to merge 8 commits into
mainfrom
feat/import-via-download
Open

MrScripty wants to merge 8 commits into
mainfrom
feat/import-via-download

Conversation

@MrScripty

Copy link
Copy Markdown
Owner

Summary

This implements docs/plans/import-via-download/plan.md. A local import is now a download whose bytes are already on disk.

  • Reverse search (model_library::source_identification). Candidates come from the caller's claim, GGUF general.repo_url/general.source.*, GGUF general.base_model.* and their -GGUF siblings, and Hugging Face search by the original file names.
    • A candidate is confirmed only when every weight file equals one of its published LFS files by SHA-256, at the commit main resolves to.
    • Several byte-identical repositories are reported as ambiguous.
    • Truncated, partial and name-only matches always need confirmation.
    • When the Hub can't be reached, the result is unavailable.
  • plan_model_import is read-only. It builds the exact-files DownloadRequest a user would have made, prepares it at that commit, and resolves the same file selection a download makes (payload, shards, companions). It reports each file as local, truncated or missing, and gives the model ID, artifact ID and destination.
  • start_source_import rebuilds the plan in the backend.
    • It seeds the (absent) download destination with the verified local bytes, hashing them while it copies.
    • It then starts the ordinary download at that commit. The download re-verifies the seeds, fetches only what is missing, and finalizes through the normal importer, so the record is a download record by construction.
    • Missing files are fetched only with consent (fetch_missing). Without consent the import is refused and the missing files are named.
  • reidentify_imported_models (dry run by default) repairs existing copied imports in place. It works from their recorded digests and original names and applies only byte-confirmed sources.
  • Refetch and the file lookup now use the reverse search.
    • Refetch no longer derives owner/name from the model ID's family segment.
    • Name matches always require confirmation.
  • Downloads. Finished downloads no longer keep pending_online_lookup: true.
  • Wizard. It now shows the backend's results instead of matching on its own:
    • removed extractEmbeddedRepoId/buildEmbeddedMetadataMatch;
    • never forwards a match that needs confirmation;
    • renders plan_model_import, with one consent checkbox for fetching missing files;
    • imports verified single files through start_source_import.

API for the GUI redesign and RPC consumers (additive)

Method Params Result
plan_model_import {items: [{path, repo_id?}]} {success, plans: ModelImportPlan[]}: identification {status, source?, candidates[], local_files[], embedded_metadata, reasons[]}, package? {repo_id, revision, requested_files, model_id, selected_artifact_id, model_type, destination, files[{repo_path, size, sha256, state: local|truncated|missing, local_path}], missing_files, missing_bytes, existing_model_id}, ingest: download|copy, requires_fetch_consent, reasons[]
start_source_import {path, repo_id, revision?, fetch_missing} {success, import: {download_id, model_id, repo_id, revision, ingested_files, fetched_files}}. Track completion like any download.
reidentify_imported_models {model_ids?: string[], dry_run?: bool (default true)} {success, report: {dry_run, items: [{model_id, identification, changes: {field: [old, new]}, applied, reasons}]}}

The TS types are in frontend/src/types/api-import.ts. lookup_hf_metadata_for_file keeps its shape. It now returns hash/1.0 only for confirmed bytes, and requires_confirmation: true for anything weaker.

Acceptance evidence

  • 0.8.0 lookup bugs. Each has a regression test (table in the plan).
  • A1 (simulated Hub). import_of_published_bytes_equals_a_download_of_them compares the import's whole metadata.json with a download's, ignoring timestamps. It also checks that the weights were not transferred again and that README.md was fetched only with consent.
  • A1 (live, real huggingface.co, scratch roots).
    • The source was the real library's Qwen3-Reranker-0.6B.Q8_0.gguf, read only. With no claim, it was confirmed as mradermacher/Qwen3-Reranker-0.6B-GGUF@6727da81 by SHA-256.
    • The plan's artifact ID equals the one the library's earlier download of that file carries.
    • Import (weights from disk, README fetched) and a fresh download of the same request produced records equal in all 66 fields, ignoring timestamps.
  • A5 (dry run, read-only, real 0.8.0 test imports).
    • LFM3-Audio-2B: confirmed LiquidAI/LFM3-Audio-2B-GGUF@39670cb5, for both the Q4_0 GGUF and the mmproj. The safetensors original and 8 other LFM3 repositories were checked and do not publish these bytes.
    • Qwen3-Reranker-0.6B Q8_0: confirmed ggml-org/Qwen3-Reranker-0.6B-Q8_0-GGUF@a02f48bb. Six mirrors publish identical bytes; the recorded claim chose ggml-org. Without it the result is ambiguous, by design.
    • Not applied (D5).
  • Checks run.
    • cargo test -p pumas-library --lib: 2212 passed.
    • cargo test -p pumas-rpc: 485 + 30 passed.
    • clippy -D warnings passes, both workspace-default and the CI feature set.
    • frontend: check:types, lint, model-import vitest.
    • electron: validate, lint, test (304 passed).

Decisions pending owner (see plan)

D2 diffusers/sharded sets stay copy imports. D3 no automatic pending-lookup job. D4 only main's commit is compared. D5 apply re-identification to the real library. D6 placement of hint-less downloads (unknown/<owner>).

Not done

S4b: a truncated local file is reported and then fetched whole (with consent); it is not yet resumed.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VkfbGSuzL9SpH8epTy2hMe

MrScripty and others added 4 commits December 1, 2026 01:33
…nloads

A local import is now a download whose bytes are already on disk.

- model_library::source_identification searches backwards from local files
  to their repository: the caller's claim, GGUF embedded repo and base-model
  URLs (and their -GGUF siblings), and Hugging Face search by the original
  file names nominate candidates. A candidate is confirmed only when every
  weight file equals a published LFS file by SHA-256 at a resolved commit.
  Byte-identical mirrors are reported as ambiguous; truncated, partial and
  name-only matches always require confirmation; offline is unavailable.
- plan_model_import (read-only) builds the exact-files download a user would
  have made, resolves its selection and destination, and reports which files
  are local, truncated or missing.
- start_source_import rebuilds the plan, seeds the download destination with
  the verified local bytes and runs the ordinary download at that commit, so
  finalization writes a download record. Missing files are fetched only with
  consent (fetch_missing) and are named when it is withheld.
- reidentify_imported_models re-identifies existing records in place from
  their recorded digests and original names; dry run by default.
- The file lookup and refetch now use the reverse search. Refetch never
  derives a repo from the model ID's family segment; name matches always
  require confirmation. Finished downloads no longer stay
  pending_online_lookup.

Each 0.8.0 lookup bug has a regression test; an integration test compares
an import with a download of the same files field by field.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VkfbGSuzL9SpH8epTy2hMe
The import wizard no longer derives repository IDs from embedded GGUF
metadata or forwards a match that needs confirmation. It renders the
backend's plan_model_import result, offers one consent control for fetching
files a verified copy lacks, and imports verified single files through
start_source_import; everything else stays a copied import.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VkfbGSuzL9SpH8epTy2hMe
Rebase the plan on current main, record the slices as implemented, the live
acceptance evidence against the real Hub, and the decisions left to the
owner.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VkfbGSuzL9SpH8epTy2hMe
@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f9b0a268-a701-4ea8-8579-66b835b92a9c
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@greptile-apps

greptile-apps Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 3/5 · Fix premature import success and the handling of local companions before merging.RetriggerView in GreptileConfidence Score: 3/5

[Medium impact] The changes affect local model imports and several source-metadata workflows.

Fix premature import success and the handling of local companions before merging.

Findings

  1. P1 Imports succeed before they finish ▶
  2. P1 Local companions count as missing ▶
  3. P2 Previews change the index ▶
  4. P2 Repairs skip unlisted changes ▶
  5. P2 Identical copies break seed creation ▶

Summary

The PR identifies local model sources by SHA-256 and seeds ordinary downloads with verified local weights. It adds planning, source-import, and re-identification APIs, plus wizard consent controls.

  • Source lookups check model bytes before treating a repository as a match.
  • Confirmed local model files can enter the library through a download.
  • Existing copied imports can be matched to their source from recorded file evidence.
  • Finished downloads no longer stay marked as waiting for an online lookup.

MrScripty explicitly defers truncated-file resume, wizard ingestion of directories and sharded sets, automatic lookup jobs, historical revision searches, applying repairs to the real library, and hint-less model placement. The plan also acknowledges the crash gap between seeding and download admission; none is reported as a finding.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Local files] --> B[Search candidate repositories]
  B --> C[Compare SHA-256 at pinned commit]
  C --> D[Plan shared download selection]
  D --> E{Fetch consent needed?}
  E -->|Granted or unnecessary| F[Copy verified seeds]
  E -->|Not granted| G[Refuse source import or use copy import]
  F --> H[Admit ordinary download]
  H --> I[Verify seeds and fetch missing files]
  I --> J[Finalize and index model]
  H --> K[Wizard currently reports success]
Loading

Reviews (1) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

MrScripty and others added 3 commits December 1, 2026 02:00
- Identical local copies map to distinct published files, preferring each
  file's own original path, so seeding never creates one path twice.
- A local LFS companion whose bytes equal its published SHA-256 is seeded
  instead of being reported missing; files published without a SHA-256 are
  still fetched, because the download verifies them by transfer.
- A re-identification dry run no longer registers pending task mappings, and
  its report lists every changed field; any change is what gets saved.
- The wizard reports a source import as a started download instead of a
  finished import.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VkfbGSuzL9SpH8epTy2hMe
@MrScripty

Copy link
Copy Markdown
Owner Author

CI on 091f522 passed every job except Review Linux inference candidate. That job fails in verify_synthetic_packaged_onnx.py (the ONNX Runtime GitHub 404), and it fails the same way on main since #159/#160. Merged main, which now includes the fix from #186, to re-run it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant