Skip to content

GGUF Model Manager with download, verification, and lifecycle #1000

Closed

Description

@malibio

Overview

Implement the model manager that handles GGUF model discovery, download with resume support, SHA256 verification, and lifecycle state tracking. This is self-contained infrastructure — it manages files on disk and reports status, but does not perform inference.

Includes automatic model selection based on system RAM to simplify first-launch onboarding.

Acceptance Criteria

  • ModelManager trait from Shared types, traits, and interface contracts for agent subsystems #998 fully implemented
  • Auto-selects model based on system RAM: >16GB -> 8B, <=16GB -> 3B
  • Exposes recommended_model() returning the RAM-appropriate ChatModelSpec
  • Download from HuggingFace with HTTP range-request resume
  • SHA256 verification passes for valid files, rejects corrupted files
  • Cancellation stops download and cleans up .partial file
  • Disk space check prevents download when insufficient space
  • Model listing correctly merges catalog with on-disk state
  • Directory creation if ~/.nodespace/models/ does not exist
  • Integration test: download a small test file, verify SHA256, report progress
  • Code passes bun run quality:fix

Technical Specifications

New Module

  • packages/desktop-app/src-tauri/src/local_agent/model_manager.rs

Model Catalog (Hardcoded v1)

Model File Size URL
Ministral 3B Q4_K_M Ministral-3-3B-Instruct-2512-Q4_K_M.gguf 2.0 GB HuggingFace mistralai
Ministral 8B Q4_K_M Ministral-3-8B-Instruct-2512-Q4_K_M.gguf 4.8 GB HuggingFace mistralai

RAM Detection

  • Use sysinfo crate to detect total system memory
  • 16GB -> recommend 8B (deeper reasoning, vision capable)

  • <=16GB -> recommend 3B (fast, lightweight, identical tool reliability)
  • Store recommendation as ChatModelSpec accessible via recommended_model()

Download Implementation

  • HTTP Range requests for resume (HuggingFace CDN supports Accept-Ranges: bytes)
  • Partial files stored with .partial extension
  • Progress via callback (DownloadEvent::Progress)
  • Cancellation via tokio CancellationToken
  • SHA256 stream-hash after download, delete file if mismatch

Status State Machine

NotDownloaded -> Downloading { progress_pct, bytes_downloaded } -> Verifying -> Ready -> Loaded -> Error(String)

Model Directory

  • Default: ~/Library/Application Support/NodeSpace/models/ (macOS)
  • Scan for existing .gguf files, match against catalog by filename
  • Report unknown models as "unrecognized"

Reference Files

  • packages/desktop-app/src-tauri/src/app_services.rs — service patterns
  • packages/nlp-engine/src/config.rs — model path resolution

Exports

  • GgufModelManager struct implementing ModelManager

Dependencies

Related Issues

Activity

  1. malibio commented on Apr 3, 2026

    @malibio
    CollaboratorAuthor

    Baseline: frontend tests have pre-existing vitest startup error (TypeError in vitest internals). Rust-only changes in this issue.

  2. self-assigned this
    on Apr 3, 2026
  3. added 2 commits that reference this issue on Apr 3, 2026
    11614e9
    225571b
  4. added 2 commits that reference this issue on Jun 22, 2026
    26cd03b
    f179ec2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions