5 Commits
Author SHA1 Message Date
carlotestor 2dd1366033 fix: fingerprint .env values, parse manifests like the agent, gate stale models fallback on sources 2026-09-24 15:29:51 +00:00
carlotestor 7344c8df77 refactor: shrink profile-switch models cache diff
Reuse _get_models_cache_path(profile) for profile delete/create instead of a
second path helper, derive the fingerprint home from the auth store path, fold
the three switch test files into one parametrized file, and trim comments/docs.
Behaviour, source axes and switch fast path are unchanged.
2026-09-23 19:11:19 +00:00
carlotestor 7f2e812280 fix: fingerprint .env key names and provider plugins; drop a profile's models cache on delete/create
A retained per-profile snapshot is now rejected after a switch when the target
profile's .env credential set or model-provider plugins changed, and a
recreated same-name profile no longer inherits the deleted profile's catalog.
2026-09-23 15:31:44 +00:00
carlotestor 217a2fcea8 review: document delete_disk invalidation modes; assert switch route kwargs via executed handle_post
- docs/architecture/models-cache-invalidation.md: add 'Invalidation modes'
  section describing delete_disk=True/False and why /api/profile/switch
  uses the memory-only mode (fingerprint-guarded per-profile disk cache).
- tests: replace the source-text scan of the switch route with two executed
  routes.handle_post tests: one captures invalidate_models_cache kwargs and
  asserts exactly [((), {'delete_disk': False})]; one runs the real
  invalidate_models_cache and asserts the disk file survives while the
  in-memory catalog is dropped. Both fail if the route reverts to the
  default delete_disk=True.
2026-09-20 11:19:41 +00:00
carlotestor 7bb12d0aab fix: keep per-profile models disk cache across /api/profile/switch
POST /api/profile/switch called invalidate_models_cache(), whose
test-isolation contract also unlinks models_cache.<profile>.json. On a
switch nothing about the sources changed, so the delete only forced a
full cold rebuild (live provider fetch_models HTTPS calls, ~490k deepcopy
calls) on the very next /api/models — several seconds on every switch.

The disk cache is already keyed per profile and rejected on read when
_models_cache_source_fingerprint() differs, so it is safe to keep. Add a
delete_disk keyword (default True — every existing caller keeps the old
behaviour) and have the switch route pass delete_disk=False.

Regression tests cover: memory-only drop preserves the disk file, default
call still unlinks it, the next get_available_models() serves the disk
snapshot without a live rebuild, and the switch route opts out. Two
existing zero-arg stubs of invalidate_models_cache accept **kwargs now.
2026-09-20 11:19:41 +00:00