Skip to content

fix(models): reject remote-only options for local sources#145

Merged
leehack merged 2 commits into
mainfrom
docs/issue-137-local-modelsource-options
May 14, 2026
Merged

fix(models): reject remote-only options for local sources#145
leehack merged 2 commits into
mainfrom
docs/issue-137-local-modelsource-options

Conversation

@leehack

@leehack leehack commented May 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • Reject non-default remote/download-only ModelLoadOptions for local ModelSource.path(...) inputs with a typed LlamaUnsupportedException instead of silently ignoring them.
  • Preserve the meaningful local-path options: cancellation before local filesystem work and optional local SHA-256 verification.
  • Document the local-vs-remote option boundary across API docs, README, website guide, and changelog.
  • Add regression coverage at both the download-manager layer and the public LlamaEngine.loadModelSource(...) path.

Closes #137

Production-readiness scope

  • Users can keep using local ModelSource.path(...) sources with default options, cancellation, and optional sha256 verification.
  • Supported platforms/paths: native/file-backed local paths through DefaultModelDownloadManager; remote URL/cache flows are unchanged.
  • Unsupported combinations fail loudly: local paths now reject non-default cachePolicy, cacheDirectory, bearer tokens, custom headers, resume: false, and custom maxRetries before local metadata is returned.
  • Existing APIs remain source-compatible; this tightens runtime validation for previously ignored local-source download/cache knobs.
  • Nuance: default-valued options remain accepted because the options object cannot distinguish explicit defaults from omitted values.

Intentionally deferred follow-ups

Test Plan

  • dart format --output=none --set-exit-if-changed lib/src/core/models/model_load_options.dart lib/src/core/models/download/model_download_manager_base.dart lib/src/platform/io/model_download_manager_io.dart test/unit/platform/io/model_download_manager_io_test.dart test/unit/core/engine/engine_test.dart
  • dart analyze
  • dart analyze lib/src/core/models/model_load_options.dart lib/src/core/models/download/model_download_manager_base.dart lib/src/platform/io/model_download_manager_io.dart test/unit/platform/io/model_download_manager_io_test.dart test/unit/core/engine/engine_test.dart
  • dart test test/unit/platform/io/model_download_manager_io_test.dart
  • dart test test/unit/core/engine/engine_test.dart
  • dart test -p vm -j 1 --exclude-tags local-only --reporter compact (840 passed, 1 skipped)
  • git diff --check origin/main
  • After Copilot feedback fix: dart analyze test/unit/core/engine/engine_test.dart lib/src/platform/io/model_download_manager_io.dart test/unit/platform/io/model_download_manager_io_test.dart
  • After Copilot feedback fix: dart test test/unit/core/engine/engine_test.dart
  • After Copilot feedback fix: dart test test/unit/platform/io/model_download_manager_io_test.dart
  • CI for efb2aa89ed49d293adcc04fcfe5741c4703903da: all required jobs passing

Review Notes

  • Independent deep review found no blockers.
  • Follow-up review suggestions addressed before PR submission: added explicit local cancellation coverage and a public LlamaEngine.loadModelSource(...) local remote-only option regression test.
  • Copilot flagged the first public regression test for a browser-unsafe top-level dart:io import; fixed by removing filesystem use from that test while keeping the public rejection coverage.
  • No active unresolved review threads remain after the latest push; the earlier Copilot thread is outdated.
  • Static scan found no hardcoded secrets, dangerous execution patterns, or raw URL logging additions.

Make local ModelSource.path handling fail loudly for non-default download/cache-only options while preserving cancellation and optional local SHA-256 verification. Update API docs, README, website guide, changelog, and regression coverage for the local path semantics.
Copilot AI review requested due to automatic review settings May 14, 2026 09:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR tightens local ModelSource.path(...) handling so remote/download-only ModelLoadOptions are rejected instead of ignored, while preserving local cancellation and SHA-256 verification behavior.

Changes:

  • Added local-source option validation in the IO download manager.
  • Added regression tests for manager-level and engine-level rejection paths.
  • Updated API docs, README, website guide, and changelog to document local-vs-remote option semantics.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
lib/src/platform/io/model_download_manager_io.dart Rejects unsupported remote/cache options for local path sources.
lib/src/core/models/model_load_options.dart Documents supported local path option semantics.
lib/src/core/models/download/model_download_manager_base.dart Documents expected local-source behavior for managers.
test/unit/platform/io/model_download_manager_io_test.dart Adds manager regression tests for rejection and cancellation.
test/unit/core/engine/engine_test.dart Adds public engine regression coverage for local option rejection.
README.md Documents local path option boundary.
website/docs/guides/model-lifecycle.md Updates lifecycle guide with local path semantics.
CHANGELOG.md Records the behavior change.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/unit/core/engine/engine_test.dart Outdated
@codecov-commenter

codecov-commenter commented May 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.25%. Comparing base (4ac67a0) to head (efb2aa8).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #145      +/-   ##
==========================================
+ Coverage   78.22%   78.25%   +0.02%     
==========================================
  Files          75       75              
  Lines        9703     9715      +12     
==========================================
+ Hits         7590     7602      +12     
  Misses       2113     2113              
Flag Coverage Δ
unittests 78.25% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@leehack leehack merged commit 05cb9e9 into main May 14, 2026
6 checks passed
@leehack leehack deleted the docs/issue-137-local-modelsource-options branch May 14, 2026 11:05
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.

docs(models): clarify local ModelSource option semantics

3 participants