fix(llm): reject registrations with colliding cache paths #6005
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.53) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.53 · 518 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.374
Shallow Review Depth
shallow_review_depth
0.289
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #6005"
general
weight: 0.35
Jackmeson1
What happens
At
47467ffa, customqwen2_5-instructand built-inqwen2.5-instructcan register together but use the same cache directory. Atf08f7e9e, customQwen2_5-instructstill collides on a filesystem that ignores case.Windows marker-file probes showed each selection returning the other's cached files in both creation orders. The custom-first probe used a directory junction; the built-in-first probe used a constructed cache directory. No model weights were loaded.
Cause
Registration compares names literally, while cache paths replace
.with_. Case-insensitive lookup can make differently cased paths identify the same directory.Change
Add an LLM cache-identity check under the registration lock, before insertion or persistence. Compare computed cache paths against built-in and registered families; conflicts raise
ValueError, surfaced as HTTP 400.Inspect existing entries inside the cache parent first. When they cannot establish case behavior, create the parent if needed and use a unique temporary directory inside it, removing the probe afterward. Case-only variants remain distinct on a case-sensitive cache directory after cache cleanup when probing succeeds. If existing entries and the temporary probe cannot establish case behavior, both new registrations and startup loading conservatively use casefolded comparison, which can still reject a legitimate case-only pair. Unicode normalization is outside this change.
Within-family hub sharing remains allowed. Conflicting persisted definitions are skipped with a warning and their JSON files remain. A legacy collision can prevent worker handoff. Existing shared cache contents are not repaired.
The registration tests use their own registry, family list and engine tables. A real-filesystem regression persists the Qwen case-only pair and reloads it after emptying or removing
v2; it skips only when directory creation establishes that the cache parent ignores case. Probe tests cover empty and missing parents, cleanup, and failures.Tests
I ran
f6b201a7on Windows with Python 3.14.6 and 3.10.20,PYTHONPATH=.,HF_HUB_OFFLINE=1,TRANSFORMERS_OFFLINE=1and a temporaryXINFERENCE_HOME:With a persisted
my-qwenloaded at startup, both versions reported 24 passed, 2 skipped, 154 deselected; the two skips are the cache-cleanup reloads, because an ordinary NTFS directory ignores case. With--basetempin a directory marked case sensitive (fsutil file setCaseSensitiveInfo), the same selection gave 26 passed on both versions; there, with the production code of41d68c7a, both cache-cleanup reloads fail (13 of the 16 cleanup and probe tests fail). With the previous fixture, the persistedmy-qwenmade one test fail with the duplicate-name error.The whole family file gave 6 failed, 169 passed, 5 skipped on each version, versus 6 failed, 152 passed, 3 skipped at
f08f7e9e; the same six tests fail for offline downloads, unavailable symlinks or the missing llama.cpp engine. Targeted pre-commit checks passed.On Ubuntu 24.04.5 with Python 3.12.3 and 3.10.22, the changed test file gave 177 passed, 2 skipped (175 passed with the CI pin Transformers 4.57.6), with the cache-cleanup reloads running; with the production code of
41d68c7athey fail because startup leaves the custom model unregistered. The other failures (test_query_engine_general, plustest_engine_discovery_paths_agree_on_draft_supporton the pin) also fail at41d68c7a. I could not run it on macOS.AI disclosure: this was prepared with AI assistance (Claude Opus 5.5 and Claude Sonnet 5.5).
🤖 Generated with Claude Code
https://claude.ai/code/session_01JfvcPZyKcKQUG9fQGYfRMw