Skip to content

Design model pack cache/download contract for installer mode#350

Merged
Abhash-Chakraborty merged 5 commits into
Abhash-Chakraborty:mainfrom
palak170306-design:feature/model-cache-design
Jul 12, 2026
Merged

Design model pack cache/download contract for installer mode#350
Abhash-Chakraborty merged 5 commits into
Abhash-Chakraborty:mainfrom
palak170306-design:feature/model-cache-design

Conversation

@palak170306-design

@palak170306-design palak170306-design commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds the design for installer-mode model pack downloading/caching, plus the
thin interfaces (ModelPack, PackCategory, PackStatus, PackProgress,
PackCache) that a future implementation will build on. This keeps the
installer small while allowing Find to run ML fully locally after models
are downloaded, with explicit size/progress/verification/retry/offline
behavior instead of invisible first-run downloads.

Fixes #45

Type of change

  • Bug fix
  • Feature
  • Documentation update
  • Refactor
  • CI / tooling

What changed

  • Added docs/plans/partial/model-cache-design.md: versioned pack manifest schema (source, license, size, checksum, compatibility), first-run selection/disk-space-preview/progress/cancel/resume/retry UX, atomic install + corrupted-cache recovery, cache-location config, and offline reuse — verified against the actual loader/config names in find_api/ml/ and core/config.py.
  • Added backend/src/find_api/core/model_pack.py: thin ModelPack dataclass, PackCategory/PackStatus enums, PackProgress, and a PackCache protocol with a NotImplementedPackCache placeholder. No existing ML loader is modified.
  • Added MODEL_CACHE_DIR and ML_OFFLINE_ONLY settings to backend/src/find_api/core/config.py, both defaulted so Docker/full/mock/remote dev modes are unaffected.
  • Documented the two new settings in .env.example.
  • Linked the new design doc from docs/plans/partial/local-first-roadmap.md's "Follow-up implementation work" list.
  • Added backend/tests/test_model_pack.py covering the new thin interfaces.

Screenshots / recordings (for UI changes)

N/A — this PR is design + backend interfaces only, no UI changes.

How to test

cd backend
pytest tests/test_model_pack.py -v
pytest tests/ -v   # confirm config.py changes don't break existing tests, e.g. test_remote_ml_config.py

Also review docs/plans/partial/model-cache-design.md against the current
find_api/ml/ loaders and core/config.py to confirm the documented model
names/settings still match.

Checklist

  • I linked the related issue
  • I ran required checks from CONTRIBUTING.md
  • I updated docs/env notes if needed
  • My PR is scoped to a single issue
  • I followed commit message conventions
  • I am not committing secrets or local artifacts

GSSoC'26 checklist

  • I requested issue assignment before starting
  • I have meaningful commits (no spam commits)
  • I am ready to explain my implementation in review comments

Summary by CodeRabbit

  • New Features
    • Added MODEL_CACHE_DIR and ML_OFFLINE_ONLY settings to enable local-only model reuse and configurable caching.
    • Introduced a model-pack contract covering pack identity/versioning, category, install status, and per-pack progress reporting for installer-mode downloads.
  • Documentation
    • Added a “Model Pack Cache & Download Design (Installer Mode)” document and updated the local-first roadmap link.
  • Tests
    • Added unit tests for pack metadata immutability, default progress values, category coverage, and placeholder cache error behavior.

@github-actions

github-actions Bot commented Jul 11, 2026

Copy link
Copy Markdown

PR Context Summary

Suggested issue links

  • No strong issue match found yet.

Use Fixes #123 or Closes #123 in the PR body when one of the suggestions is the intended issue.
Manual rerun: Actions > PR Context Triage > Run workflow > set pr_number and force_review=true.

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f4cfbe41-badb-43d1-b979-7247a337494f

📥 Commits

Reviewing files that changed from the base of the PR and between f5bf5a1 and 4f66db3.

📒 Files selected for processing (2)
  • backend/src/find_api/core/model_pack.py
  • backend/tests/test_model_pack.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • backend/tests/test_model_pack.py
  • backend/src/find_api/core/model_pack.py

📝 Walkthrough

Walkthrough

Adds configurable model-cache and offline settings, immutable versioned model-pack metadata and cache lifecycle interfaces, installer-mode design documentation, a placeholder backend, and focused pytest coverage.

Changes

Model pack installer contract

Layer / File(s) Summary
Pack metadata and configuration
backend/src/find_api/core/config.py, backend/src/find_api/core/model_pack.py, .env.example
Adds cache/offline settings, pack categories, and immutable metadata for version, source, license, size, checksum, compatibility, and configuration mapping.
Cache lifecycle contract
backend/src/find_api/core/model_pack.py
Defines pack statuses, progress snapshots, cache operations, and a placeholder implementation that raises NotImplementedError.
Contract validation
backend/tests/test_model_pack.py
Tests metadata fields, immutability, progress defaults, category construction, and placeholder cache behavior.
Installer cache design
docs/plans/partial/model-cache-design.md, docs/plans/partial/local-first-roadmap.md
Documents model-pack selection, progress, cancellation, resumption, verification, corrupted-cache recovery, offline reuse, and links the roadmap item to the design.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: abhash-chakraborty, macroscopeapp

Poem

I’m a bunny with packs in a row,
With checksums to verify each show.
Cache paths tucked neat,
Offline runs complete,
And progress hops softly below.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: an installer-mode model pack cache/download contract.
Description check ✅ Passed The description follows the template well, including summary, issue link, change type, what changed, testing, and checklist items.
Linked Issues check ✅ Passed The changes match issue #45's requirements for pack metadata, offline/cache settings, UX design, and focused interface tests.
Out of Scope Changes check ✅ Passed The PR stays within the requested design-and-contract scope and only adds related docs, settings, and tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

Comment @coderabbitai help to get the list of available commands.

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jul 11, 2026
@macroscopeapp

macroscopeapp Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved

This PR adds design documentation and interface contracts (Protocol/dataclasses) for a future model pack cache system. All implementation methods raise NotImplementedError, the new config settings have inert defaults, and no existing code paths are modified - zero runtime behavior change.

You can customize Macroscope's approvability policy. Learn more.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
backend/src/find_api/core/config.py (1)

50-51: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Consider a cross-field validator for ML_OFFLINE_ONLY with MODEL_CACHE_DIR.

When ML_OFFLINE_ONLY=True, models must be served from cache, which requires MODEL_CACHE_DIR to point to a valid directory. The existing validate_remote_ml_config validator follows the same pattern for ML_MODE=remote. Adding a similar guard would catch misconfigured deployments early, though this can wait until the cache implementation lands.

♻️ Suggested validator
     MODEL_CACHE_DIR: str = ""
     ML_OFFLINE_ONLY: bool = False
+
+    `@model_validator`(mode="after")
+    def validate_offline_cache_config(self):
+        """Require a cache directory when offline-only mode is enabled."""
+        if self.ML_OFFLINE_ONLY and not self.MODEL_CACHE_DIR.strip():
+            raise ValueError(
+                "ML_OFFLINE_ONLY requires MODEL_CACHE_DIR to be set "
+                "so models can be loaded from the local cache."
+            )
+        return self
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/src/find_api/core/config.py` around lines 50 - 51, Extend the
existing validate_remote_ml_config validation to also cover ML_OFFLINE_ONLY:
when it is true, require MODEL_CACHE_DIR to be configured as a valid directory,
while leaving current validation unchanged for other modes. Reuse the existing
cross-field validation pattern and defer enforcement only if cache support is
not yet available.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@backend/src/find_api/core/model_pack.py`:
- Around line 87-95: Update the install method’s on_progress annotation to use
the typing Callable type instead of the builtin callable, importing Callable
from typing or collections.abc while preserving the existing PackProgress
argument and optional callback behavior.

---

Nitpick comments:
In `@backend/src/find_api/core/config.py`:
- Around line 50-51: Extend the existing validate_remote_ml_config validation to
also cover ML_OFFLINE_ONLY: when it is true, require MODEL_CACHE_DIR to be
configured as a valid directory, while leaving current validation unchanged for
other modes. Reuse the existing cross-field validation pattern and defer
enforcement only if cache support is not yet available.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c7fb4c66-5404-4107-bed4-7af0baa8a64b

📥 Commits

Reviewing files that changed from the base of the PR and between a1c2ee8 and 4264d7c.

📒 Files selected for processing (3)
  • backend/src/find_api/core/config.py
  • backend/src/find_api/core/model_pack.py
  • backend/tests/test_model_pack.py

Comment thread backend/src/find_api/core/model_pack.py
@Abhash-Chakraborty Abhash-Chakraborty added enhancement New feature, improvement, or enhancement request. documentation Documentation, README, guide, or text improvement. backend FastAPI, database, storage, and API work ml Model inference, embeddings, OCR, captions, and search relevance desktop-app Windows, macOS, and Linux installed app work packaging Installers, bundles, signing, releases, and distribution performance Speed, startup, memory, image size, and runtime efficiency local-first Privacy-preserving local runtime and offline behavior testing Automated tests or manual QA coverage priority: high Important issue that should be handled soon assigned Issue or PR is already assigned to someone. gssoc26 Related to GirlScript Summer of Code 2026. gssoc Related to GirlScript Summer of Code. type:feature Feature PR. GSSoC type bonus. type:docs Documentation-related PR. GSSoC type bonus: +5 points. type:testing Testing-related PR. GSSoC type bonus: +10 points. under-review Maintainer needs to verify do-not-merge Blocks merging. Remove this label only when the PR is fully ready for production. labels Jul 11, 2026
@macroscopeapp macroscopeapp Bot dismissed their stale review July 11, 2026 14:24

Dismissing prior approval to re-evaluate 4264d7c

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jul 11, 2026

@Abhash-Chakraborty Abhash-Chakraborty left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good direction, but please fix the failing backend check: remove the unused field import and use Callable instead of callable for the progress callback. Then rerun the backend checks.

@macroscopeapp macroscopeapp Bot dismissed their stale review July 11, 2026 17:20

Dismissing prior approval to re-evaluate f5bf5a1

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jul 11, 2026
@macroscopeapp macroscopeapp Bot dismissed their stale review July 12, 2026 19:58

Dismissing prior approval to re-evaluate 4f66db3

@gitguardian

gitguardian Bot commented Jul 12, 2026

Copy link
Copy Markdown

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

Since your pull request originates from a forked repository, GitGuardian is not able to associate the secrets uncovered with secret incidents on your GitGuardian dashboard.
Skipping this check run and merging your pull request will create secret incidents on your GitGuardian dashboard.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
34345071 Triggered Generic Password 329215e docker-compose.yml View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@Abhash-Chakraborty

Copy link
Copy Markdown
Owner

Maintainer follow-up completed: rebased this branch onto current main, applied Ruff formatting to the model-pack contract/tests, and verified the focused model-pack plus remote-config suite locally. GitHub CI, CodeQL, hardware matrix, frontend/backend checks, and TestSprite are green. The cross-field offline-cache validator remains intentionally deferred until the filesystem-backed cache implementation exists, as documented by this design PR.

@Abhash-Chakraborty Abhash-Chakraborty left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The scoped design and interfaces match #45, are now formatted and tested, and do not alter existing loaders. Approved after maintainer verification.

@Abhash-Chakraborty Abhash-Chakraborty added ready-to-merge Fully approved, tested, and cleared for immediate merging. and removed under-review Maintainer needs to verify do-not-merge Blocks merging. Remove this label only when the PR is fully ready for production. labels Jul 12, 2026
@Abhash-Chakraborty Abhash-Chakraborty merged commit d4b4332 into Abhash-Chakraborty:main Jul 12, 2026
17 of 19 checks passed
@github-actions

Copy link
Copy Markdown

@macroscope-app review

Please review this PR against its linked issue, local-first privacy rules, and the current Find repo instructions.
Linked issue(s): #45.
Trigger source: label-gated review (ready-to-merge).

@Abhash-Chakraborty Abhash-Chakraborty added the gssoc:approved Valid GSSoC contribution approved for scoring. label Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

assigned Issue or PR is already assigned to someone. backend FastAPI, database, storage, and API work desktop-app Windows, macOS, and Linux installed app work documentation Documentation, README, guide, or text improvement. enhancement New feature, improvement, or enhancement request. gssoc:approved Valid GSSoC contribution approved for scoring. gssoc Related to GirlScript Summer of Code. gssoc26 Related to GirlScript Summer of Code 2026. local-first Privacy-preserving local runtime and offline behavior ml Model inference, embeddings, OCR, captions, and search relevance packaging Installers, bundles, signing, releases, and distribution performance Speed, startup, memory, image size, and runtime efficiency priority: high Important issue that should be handled soon ready-to-merge Fully approved, tested, and cleared for immediate merging. testing Automated tests or manual QA coverage type:docs Documentation-related PR. GSSoC type bonus: +5 points. type:feature Feature PR. GSSoC type bonus. type:testing Testing-related PR. GSSoC type bonus: +10 points.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: design installer model downloads and cache management

2 participants