Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
feat(ollama): the catalogue browses newest and popular with capability filters, and the shortlist is this month's
rubenluetke10-beepaa050ade0716
diff --git a/jarvis/brain/ollama_library.py b/jarvis/brain/ollama_library.pyindex a2bed8bffa..0d33d1fbb7 100644--- a/jarvis/brain/ollama_library.py+++ b/jarvis/brain/ollama_library.py@@ -9,8 +9,15 @@ Ollama publishes no JSON search API, and the registry does NOT expose theDocker ``tags/list`` endpoint (404, verified 2026-08-09). Both surfaces heretherefore parse the public web pages:-- search: ``https://ollama.com/search?q=…`` (name, blurb, badges)+- search: ``https://ollama.com/search?q=…&o=…&c=…`` (name, blurb, badges)- tag list: ``https://ollama.com/library/{name}/tags`` (tag, size, context)+ ``https://ollama.com/{user}/{model}/tags`` (community namespace)++The search page honours two query parameters, verified live 2026-08-24:+``o=newest`` orders by publication instead of popularity, and+``c=tools|vision|embedding|thinking`` keeps only models carrying that badge.+Both are forwarded verbatim by :func:`search_library`; an unknown value is+dropped rather than sent, so a typo degrades to the default listing.Scraping is a liability, so the contract is honest degradation: any fetch orparse failure answers ``{"models"/"tags": [], "error": "<English sentence>"}``@@ -58,14 +65,34 @@ _FETCH_TIMEOUT = httpx.Timeout(connect=3.0, read=10.0, write=10.0, pool=10.0)#: without ever showing a week-old catalog._CACHE_TTL_SECONDS = 600.0-#: Search answers at most this many models. The page itself shows about this-#: many above the fold, and a narrower query beats scrolling page two.-_SEARCH_LIMIT = 25--#: Library model names as they appear in ``/library/{name}`` URLs. No slash on-#: purpose: community-namespaced models (``/{user}/{model}``) are out of scope-#: here, and the pattern doubles as the URL-injection guard for the tags fetch.-_NAME_RE = re.compile(r"[A-Za-z0-9._-]+")+#: Search answers at most this many models. The page itself renders about+#: twenty per query, so this is a ceiling for a wider listing, not a cut that+#: hides rows; a narrower query still beats scrolling.+_SEARCH_LIMIT = 50++#: Sort orders the search page understands. "popular" is the page default and+#: sends nothing; only "newest" is forwarded as ``?o=newest``.+SEARCH_SORTS: tuple[str, ...] = ("popular", "newest")++#: Capability filters the search page understands (``?c=…``). Same words as+#: the badges the page renders, so a filtered listing and a badge agree.+SEARCH_CAPABILITIES: tuple[str, ...] = ("tools", "vision", "embedding", "thinking")++#: Library model names as they appear in ``/library/{name}`` URLs, plus at most+#: ONE community namespace segment (``{user}/{model}``, served from+#: ``/{user}/{model}``). The pattern doubles as the URL-injection guard for the+#: tags fetch: every segment starts with a letter or digit (so ``..`` is out),+#: no second slash, no query characters.+_NAME_RE = re.compile(r"[A-Za-z0-9][A-Za-z0-9._-]*(?:/[A-Za-z0-9][A-Za-z0-9._-]*)?")++#: Quantization as far as the TAG NAME says it — the tags page prints no+#: separate quantization column (verified 2026-08-24), so ``27b-q8_0`` is the+#: only place the fact lives. A tag without such a suffix (``latest``, ``27b``)+#: is the library's default quant and reads as an empty string, never a guess.+_QUANT_RE = re.compile(+ r"(?:^|-)((?:i?q\d(?:_[a-z0-9]+)*)|(?:bf16|fp16|f16|fp32|f32|mxfp8|nvfp4|fp8|fp4))$",+ re.IGNORECASE,+)#: Capability badges the search page renders, in display order. "cloud" is#: handled separately: it is a hosting fact, not a model capability.@@ -115,6 +142,22 @@ def _cache_get(return None+def _tags_path(name: str) -> str:+ """The page path for ``name``'s tag list.++ Library models live under ``/library/{name}``; a community model with a+ namespace lives under ``/{user}/{model}`` (``/library/{user}/{model}``+ answers 404, verified 2026-08-24).+ """+ return f"/{name}/tags" if "/" in name else f"/library/{name}/tags"+++def _quantization(tag: str) -> str:+ """The quantization a tag name declares (``q4_K_M``, ``bf16``…), or ``""``."""+ match = _QUANT_RE.search(tag)+ return match.group(1) if match else ""++def _text(fragment: str) -> str:"""Visible text of an HTML fragment: tags out, entities decoded, one space."""plain = re.sub(r"<[^>]+>", " ", fragment)@@ -207,18 +250,46 @@ def parse_search_html(page: str) -> list[dict[str, Any]]:return entries-async def search_library(query: str) -> dict[str, Any]:+async def search_library(+ query: str,+ *,+ sort: str = "popular",+ capability: str | None = None,+ limit: int = _SEARCH_LIMIT,+) -> dict[str, Any]:"""Search the public library; an empty query lists the popular models.+ ``sort`` is ``"popular"`` (the page default) or ``"newest"``;+ ``capability`` is one of :data:`SEARCH_CAPABILITIES` or ``None``. Values the+ page does not know are dropped, not sent — a stray filter must degrade to+ the plain listing, never to an error. ``limit`` caps the answer at 1..50.+``installed`` is judged against the LOCAL server's inventory, so a modelalready pulled (any tag of it) reads as such directly in the results."""q = (query or "").strip()- models = _cache_get(_search_cache, q)+ sort = sort if sort in SEARCH_SORTS else "popular"+ capability = capability if capability in SEARCH_CAPABILITIES else None+ limit = max(1, min(int(limit), _SEARCH_LIMIT))+ params: dict[str, str] = {}+ if q:+ params["q"] = q+ if sort == "newest":+ params["o"] = "newest"+ if capability:+ params["c"] = capability+ cache_key = f"{q}|{sort}|{capability or ''}"+ models = _cache_get(_search_cache, cache_key)if models is None:- page, error = await _fetch_page("/search", params={"q": q} if q else None)+ page, error = await _fetch_page("/search", params=params or None)if page is None:- return {"query": q, "models": [], "error": error}+ return {+ "query": q,+ "sort": sort,+ "capability": capability,+ "models": [],+ "error": error,+ }models = parse_search_html(page)if not models:@@ -226,16 +297,17 @@ async def search_library(query: str) -> dict[str, Any]:# that no longer parses would silently kill the feature. Only the# latter is an error, and only the live guard can tell them apart —# here both honestly say "nothing found".- log.info("ollama-library: search %r parsed 0 entries", q)- _search_cache[q] = (time.monotonic(), [dict(entry) for entry in models])+ log.info("ollama-library: search %r (%s) parsed 0 entries", q, cache_key)+ _search_cache[cache_key] = (time.monotonic(), [dict(entry) for entry in models])+ models = models[:limit]installed, _inventory_error = await installed_models()families = {i.partition(":")[0] for i in installed}for model in models:name = model["name"]model["installed"] = name in families or _is_installed(name, installed)- return {"query": q, "models": models, "error": None}+ return {"query": q, "sort": sort, "capability": capability, "models": models, "error": None}# ── tags ────────────────────────────────────────────────────────────────────@@ -246,11 +318,13 @@ def parse_tags_html(page: str, name: str) -> list[dict[str, Any]]:The page renders each tag twice (a mobile and a desktop block). Instead ofdepending on either block's classes, this walks the FIRST occurrence of- each distinct ``/library/{name}:{tag}`` href and reads the plain-text facts- ("6.6GB", "256K context window", "Text, Image input", "5 months ago") from- the window up to the next distinct tag.+ each distinct ``/library/{name}:{tag}`` (or ``/{user}/{model}:{tag}``) href+ and reads the plain-text facts ("6.6GB", "256K context window", "Text,+ Image input", "5 months ago") from the window up to the next distinct tag.+ ``quantization`` comes from the tag name alone — the page prints no other+ source for it — and ``context`` is the "256K" before "context window"."""- href_re = re.compile(rf'href="/library/{re.escape(name)}:([^"?#]+)"')+ href_re = re.compile(rf'href="/(?:library/)?{re.escape(name)}:([^"?#]+)"')matches = list(href_re.finditer(page))first_seen: list[tuple[str, int]] = []seen: set[str] = set()@@ -276,6 +350,7 @@ def parse_tags_html(page: str, name: str) -> list[dict[str, Any]]:"id": f"{name}:{tag}","size_gb": _size_to_gb(size_match) if size_match else None,"context": context_match.group(1) if context_match else "",+ "quantization": _quantization(tag),"inputs": _text(inputs_match.group(1)) if inputs_match else "","updated": updated_match.group(1) if updated_match else "",# A hosting fact from the tag NAME, never inferred from a@@ -299,7 +374,7 @@ async def library_tags(model: str) -> dict[str, Any]:return {"model": name, "tags": [], "error": "Not a valid library model name."}tags = _cache_get(_tags_cache, name)if tags is None:- page, error = await _fetch_page(f"/library/{name}/tags")+ page, error = await _fetch_page(_tags_path(name))if page is None:return {"model": name, "tags": [], "error": error}diff --git a/jarvis/brain/ollama_pull.py b/jarvis/brain/ollama_pull.pyindex cccf720c50..6a12990e5a 100644--- a/jarvis/brain/ollama_pull.py+++ b/jarvis/brain/ollama_pull.py@@ -26,6 +26,7 @@ Two deliberate choices:from __future__ import annotationsimport asyncio+import datetimeimport jsonimport loggingfrom dataclasses import dataclass@@ -101,84 +102,112 @@ class RecommendedModel:#: registry). That test is also the guard against the list going stale: a tag#: that is retired fails it rather than reaching a user as "Ollama does not know#: a model called …". Sizes are the registry's own, refreshed at request time.+#: When a maintainer last checked the shortlist against the live library.+#: Surfaced in the download panel ("Shortlist reviewed …") and enforced by+#: ``tests/integration/test_ollama_catalog_is_current.py``: a review older+#: than twelve months fails the suite, because CLAUDE.md §4 forbids shipping a+#: year-old local default. Bump it in the same commit that refreshes the list.+CURATED_REVIEWED_ON = datetime.date(2026, 8, 24)++#: How old the review above may get before the guard fails.+CURATED_MAX_AGE_DAYS = 365+RECOMMENDED_MODELS: tuple[RecommendedModel, ...] = (# ── chat / voice / tools ────────────────────────────────────────────────+ # Every chat pick that declares ``vision=True`` also serves Screen Context+ # and Computer-Use: the current families (Qwen 3.5/3.8, Gemma 4, Muse) are+ # natively multimodal, so a separate vision download is only a fallback+ # for machines below the smallest multimodal chat model.RecommendedModel(- id="qwen3.5:2b",- label="Qwen 3.5 2B",- size_gb=2.7,- purpose="Chat and voice on a small laptop. Calls tools.",+ id="granite4.1:3b",+ label="Granite 4.1 3B",+ size_gb=2.1,+ purpose="Tiny chat with tool calling for a machine with little memory.",),RecommendedModel(id="qwen3.5:4b",label="Qwen 3.5 4B",size_gb=3.4,- purpose="Chat and voice with more headroom, still light on memory.",+ purpose="Chat, voice and screen reading on a small laptop. Calls tools.",+ vision=True,+ ),+ RecommendedModel(+ id="lfm2.5",+ label="LFM 2.5 8B A1B",+ size_gb=5.2,+ purpose="Fastest tool caller of the small class; 1B parameters work per token.",),RecommendedModel(id="qwen3.5",label="Qwen 3.5 9B",size_gb=6.6,- purpose="The balanced default: chat, voice, and reliable tool calling.",+ purpose="The balanced default: chat, voice, screen reading and reliable tool calling.",+ vision=True,),RecommendedModel(id="gemma4:12b-it-qat",label="Gemma 4 12B QAT",size_gb=7.2,- purpose="Current quantized 12B chat, tools, and vision for one GPU.",+ purpose="Current quantized 12B chat with tools, vision and audio for one GPU.",+ vision=True,),RecommendedModel(id="gemma4:26b-a4b-it-qat",label="Gemma 4 26B A4B QAT",- size_gb=16.0,+ size_gb=15.6,purpose="Current sparse Gemma with stronger reasoning where memory allows.",- ),- # ── vision (Screen Context / Computer-Use) ──────────────────────────────- RecommendedModel(- id="qwen3-vl:2b",- label="Qwen 3 VL 2B",- size_gb=1.9,- purpose="Sees your screen on a small machine.",- role="vision",vision=True,),RecommendedModel(- id="qwen3-vl:4b",- label="Qwen 3 VL 4B",- size_gb=3.3,- purpose="Sees your screen, with more detail than the 2B.",- role="vision",+ id="qwen3.8:27b",+ label="Qwen 3.8 27B",+ size_gb=17.7,+ purpose="The current flagship for a large card: chat, tools, vision and thinking.",vision=True,),RecommendedModel(- id="qwen3-vl",- label="Qwen 3 VL 8B",- size_gb=6.1,- purpose="The balanced choice for Screen Context and Computer-Use.",- role="vision",- vision=True,+ id="nemotron-3.5-lightning",+ label="Nemotron 3.5 Lightning 30B A3B",+ size_gb=25.4,+ purpose="Sparse chat with a one-million-token context; 3B parameters work per token.",),+ # ── vision fallback (Screen Context / Computer-Use below 3 GB) ──────────RecommendedModel(- id="qwen3-vl:32b",- label="Qwen 3 VL 32B",- size_gb=20.9,- purpose="Reads dense screens and small text most reliably.",+ id="qwen3-vl:2b",+ label="Qwen 3 VL 2B",+ size_gb=1.9,+ purpose="Sees your screen on a machine too small for a multimodal chat model.",role="vision",vision=True,),# ── coding worker (the Agents tab's heavy-task model) ───────────────────+ RecommendedModel(+ id="ornith:9b",+ label="Ornith 9B",+ size_gb=5.6,+ purpose="Small agentic coding worker with tool calling.",+ role="coder",+ ),RecommendedModel(id="qwen3.6:27b",label="Qwen 3.6 27B",- size_gb=17.0,+ size_gb=17.4,purpose="Current dense Qwen for agentic coding and repository work.",role="coder",),RecommendedModel(- id="qwen3.6:35b-a3b",- label="Qwen 3.6 35B A3B",- size_gb=24.0,- purpose="Current sparse Qwen coding worker; 3B parameters activate per token.",+ id="muse-glimmer:30b",+ label="Muse Glimmer 30B",+ size_gb=18.2,+ purpose="Agentic coding worker with vision and thinking.",+ role="coder",+ vision=True,+ ),+ RecommendedModel(+ id="ornith:35b",+ label="Ornith 35B",+ size_gb=21.2,+ purpose="Large agentic coding worker for a big card.",role="coder",),# ── embeddings (UltraWiki search) ───────────────────────────────────────@@ -405,6 +434,11 @@ async def _real_sizes() -> dict[str, float]:return sizes+def _serves_vision(role: str, row: dict[str, Any]) -> bool:+ """Whether a chat row also counts for the vision role (multimodal chat)."""+ return role == "vision" and row["role"] == "chat" and bool(row["vision"])++def _pick_recommended(rows: list[dict[str, Any]]) -> None:"""Mark the best pick per role on ``rows``, in place.@@ -418,9 +452,17 @@ def _pick_recommended(rows: list[dict[str, Any]]) -> None:A role whose model is already installed marks nothing: the user has madethat choice, and re-recommending a different size over the top of it is howa panel starts nagging.++ The vision role is served by the multimodal CHAT picks as well as the+ dedicated vision fallback, so a machine that runs a chat model which+ already sees the screen is not told to download a second one for it. (A+ coder that happens to see images is not offered as the screen model — it+ is sized for repository work, not for a screen reader.) A row can therefore+ be the pick of more than one role; ``recommended_for`` lists them and+ ``recommended`` stays the boolean the panel already renders."""for role in ROLE_ORDER:- in_role = [r for r in rows if r["role"] == role]+ in_role = [r for r in rows if r["role"] == role or _serves_vision(role, r)]if not in_role or any(r["installed"] for r in in_role):continuecomfortable = [r for r in in_role if r["fit"] == "comfortable"]@@ -430,6 +472,7 @@ def _pick_recommended(rows: list[dict[str, Any]]) -> None:else min(in_role, key=lambda r: r["size_gb"]))pick["recommended"] = True+ pick["recommended_for"].append(role)async def recommendations() -> dict[str, Any]:@@ -462,6 +505,7 @@ async def recommendations() -> dict[str, Any]:"fit": verdict,"fit_note": note,"recommended": False,+ "recommended_for": [],})_pick_recommended(models)@@ -481,6 +525,10 @@ async def recommendations() -> dict[str, Any]:"accelerator_gb": round(accel, 1),"accelerator_source": accel_source,"roles": list(ROLE_ORDER),+ # ISO date so the panel can say "Shortlist reviewed 2026-08-24" — the+ # honest answer to "how current is this list?", next to the live+ # catalogue's own "fetched N minutes ago".+ "curated_reviewed_on": CURATED_REVIEWED_ON.isoformat(),"models": models,"installed": sorted(installed),}diff --git a/tests/fixtures/brain/ollama_tags.html b/tests/fixtures/brain/ollama_tags.htmlindex f9d35b611c..6df9e32472 100644--- a/tests/fixtures/brain/ollama_tags.html+++ b/tests/fixtures/brain/ollama_tags.html@@ -105,4 +105,31 @@</div></div></div>+ <!-- A quantization-bearing tag (added 2026-08-24). The page prints NO+ separate quantization column; the tag name is the only place the fact+ lives, which is why the parser reads it from there and nowhere else. -->+ <div class="group px-4 py-3">+ <a href="/library/qwen3.5:0.8b-q8_0" class="md:hidden flex flex-col space-y-[6px] group">+ <div class="flex items-center font-medium">+ <span class="group-hover:underline">qwen3.5:0.8b-q8_0</span>+ </div>+ <div class="flex flex-col text-neutral-500 text-[13px]">+ <span>+ <span class="font-mono">1c2d3e4f5a6b</span> • 1.1GB • 128K context window •+ <span class="hidden sm:inline">Text input • 5 months ago</span>+ </span>+ </div>+ </a>+ <div class="hidden md:flex flex-col space-y-[6px]">+ <div class="grid grid-cols-12 items-center">+ <span class="flex items-center font-medium col-span-6 group text-sm">+ <a href="/library/qwen3.5:0.8b-q8_0" class="group-hover:underline">qwen3.5:0.8b-q8_0</a>+ <input class="command hidden" value="qwen3.5:0.8b-q8_0" />+ </span>+ <p class="col-span-2 text-neutral-500 text-[13px]">1.1GB</p>+ <p class="col-span-2 text-neutral-500 text-[13px]">128K</p>+ <div class="col-span-2 text-neutral-500 text-[13px] ">Text</div>+ </div>+ </div>+ </div></main>diff --git a/tests/integration/test_ollama_catalog_is_current.py b/tests/integration/test_ollama_catalog_is_current.pyindex 15a1770818..a68d200aef 100644--- a/tests/integration/test_ollama_catalog_is_current.py+++ b/tests/integration/test_ollama_catalog_is_current.py@@ -19,12 +19,19 @@ must not go red over it. Run it explicitly with ``pytest -m integration``.from __future__ import annotations+import datetime+import httpximport pytestfrom jarvis.brain.ack_brain.config import AckBrainConfigfrom jarvis.brain.ollama_library import parse_tags_html-from jarvis.brain.ollama_pull import RECOMMENDED_MODELS, ROLE_ORDER+from jarvis.brain.ollama_pull import (+ CURATED_MAX_AGE_DAYS,+ CURATED_REVIEWED_ON,+ RECOMMENDED_MODELS,+ ROLE_ORDER,+)from jarvis.core.config import MemoryConfigfrom jarvis.dictation.polish_client import POLISH_FAMILIESfrom jarvis.realtime.local_server import brain_link, tiers@@ -36,9 +43,31 @@ pytestmark = pytest.mark.integration_REGISTRY = "https://registry.ollama.ai/v2/library"_ACCEPT = {"Accept": "application/vnd.docker.distribution.manifest.v2+json"}+#: Every tag the 2026-08-24 shortlist refresh names, listed here so a retired+#: one fails by NAME even if someone trims it from RECOMMENDED_MODELS without+#: reading this file. Verified against the registry manifests on that date.+_SHORTLIST_2026_08_24 = (+ "granite4.1:3b",+ "qwen3.5:4b",+ "lfm2.5",+ "qwen3.5",+ "gemma4:12b-it-qat",+ "gemma4:26b-a4b-it-qat",+ "qwen3.8:27b",+ "nemotron-3.5-lightning",+ "qwen3-vl:2b",+ "ornith:9b",+ "qwen3.6:27b",+ "muse-glimmer:30b",+ "ornith:35b",+ "embeddinggemma",+ "qwen3-embedding:4b",+)+_RUNTIME_OLLAMA_MODELS = tuple(sorted({+ *_SHORTLIST_2026_08_24,AckBrainConfig().providers.ollama.model,MemoryConfig().embedding_model,DEFAULT_MODELS["ollama"],@@ -125,6 +154,24 @@ def _assert_model_is_current(model_id: str, registry: httpx.Client) -> None:)+def test_the_shortlist_was_reviewed_within_twelve_months() -> None:+ """CLAUDE.md §4: nothing a year old ships as a local default. The review+ date is printed in the panel, so it must be both true and recent — the+ per-tag checks above catch a retired tag, this catches a list nobody has+ looked at."""+ age = datetime.date.today() - CURATED_REVIEWED_ON+ assert 0 <= age.days <= CURATED_MAX_AGE_DAYS, (+ f"The curated shortlist was reviewed on {CURATED_REVIEWED_ON}, "+ f"{age.days} days ago. Re-check every tag on ollama.com and bump "+ "CURATED_REVIEWED_ON in the same commit."+ )+++def test_the_shortlist_names_every_registered_tag() -> None:+ """The registry list above and RECOMMENDED_MODELS must move together."""+ assert {entry.id for entry in RECOMMENDED_MODELS} == set(_SHORTLIST_2026_08_24)++def test_every_role_still_offers_something() -> None:"""A role whose last entry is removed would silently stop being recommended— the panel would just have one fewer group, which reads as "not needed"."""@@ -137,5 +184,11 @@ def test_every_role_spans_more_than_one_size() -> None:with a single entry gives it nothing to pick from, and a small machine and aworkstation get the same answer again."""for role in ROLE_ORDER:- sizes = {e.size_gb for e in RECOMMENDED_MODELS if e.role == role}+ # The vision role is served by every multimodal pick, whichever role+ # it is filed under (see ``_pick_recommended``).+ sizes = {+ e.size_gb+ for e in RECOMMENDED_MODELS+ if e.role == role or (role == "vision" and e.role == "chat" and e.vision)+ }assert len(sizes) >= 2, f"role '{role}' offers only one size"diff --git a/tests/integration/test_ollama_library_live.py b/tests/integration/test_ollama_library_live.pyindex fc230f9923..6b56b33fe9 100644--- a/tests/integration/test_ollama_library_live.py+++ b/tests/integration/test_ollama_library_live.py@@ -15,7 +15,7 @@ from __future__ import annotationsimport httpximport pytest-from jarvis.brain.ollama_library import parse_search_html, parse_tags_html+from jarvis.brain.ollama_library import _tags_path, parse_search_html, parse_tags_htmlpytestmark = pytest.mark.integration@@ -54,3 +54,39 @@ def test_the_live_tags_page_still_parses() -> None:with_size = [t for t in tags if t["size_gb"]]assert with_size, "No parsed tag carries a download size any more."assert any(t["tag"] == "latest" for t in tags)+++def test_the_live_newest_sort_is_honoured() -> None:+ """``?o=newest`` must change the ORDER: the first rows are days or weeks+ old, never the years-old names that top the popular listing."""+ models = parse_search_html(_fetch("https://ollama.com/search?o=newest"))+ assert len(models) >= 5, "The live newest listing parsed almost empty."+ head = [m["updated"] for m in models[:5]]+ assert all(u and "year" not in u for u in head), head+ assert any(("day" in u or "week" in u or u == "yesterday") for u in head), head+++def test_the_live_capability_filter_is_honoured() -> None:+ """``?c=embedding`` must change the SET: every row carries that badge."""+ models = parse_search_html(_fetch("https://ollama.com/search?c=embedding"))+ assert len(models) >= 3, "The live embedding filter parsed almost empty."+ assert all("embedding" in m["capabilities"] for m in models), [+ m["name"] for m in models if "embedding" not in m["capabilities"]+ ]+++def test_the_live_tags_page_carries_quantized_tags() -> None:+ """A family that publishes quant variants must yield a non-empty+ ``quantization`` for them and an empty one for the default tag."""+ tags = parse_tags_html(_fetch("https://ollama.com/library/qwen3.6/tags"), "qwen3.6")+ quantized = [t for t in tags if t["quantization"]]+ assert quantized, "No tag on the live qwen3.6 page reads a quantization any more."+ assert next(t for t in tags if t["tag"] == "latest")["quantization"] == ""+ assert all(t["context"] for t in tags[:3]), "Context window no longer parses."+++def test_a_live_namespaced_model_parses_from_its_own_path() -> None:+ name = "huihui_ai/qwen3-abliterated"+ tags = parse_tags_html(_fetch(f"https://ollama.com{_tags_path(name)}"), name)+ assert len(tags) >= 2, "The live community tags page parsed almost empty."+ assert tags[0]["id"].startswith(f"{name}:")diff --git a/tests/unit/brain/test_ollama_library.py b/tests/unit/brain/test_ollama_library.pyindex 47b694717f..24b3a1dba8 100644--- a/tests/unit/brain/test_ollama_library.py+++ b/tests/unit/brain/test_ollama_library.py@@ -82,7 +82,7 @@ def test_search_parser_answers_empty_on_garbage() -> None:def test_tags_parser_dedupes_the_mobile_and_desktop_blocks(tags_page: str) -> None:tags = library.parse_tags_html(tags_page, "qwen3.5")- assert [t["tag"] for t in tags] == ["latest", "cloud", "0.8b", "0.3b"]+ assert [t["tag"] for t in tags] == ["latest", "cloud", "0.8b", "0.3b", "0.8b-q8_0"]def test_tags_parser_reads_sub_gigabyte_sizes(tags_page: str) -> None:@@ -118,6 +118,53 @@ def test_tags_parser_reads_size_context_and_inputs(tags_page: str) -> None:assert latest["cloud"] is False+def test_tags_parser_reads_quantization_from_the_tag_name(tags_page: str) -> None:+ """The page prints no quantization column, so the tag name is the only+ honest source: ``0.8b-q8_0`` says q8_0, a bare ``latest`` says nothing."""+ by_tag = {t["tag"]: t for t in library.parse_tags_html(tags_page, "qwen3.5")}+ assert by_tag["0.8b-q8_0"]["quantization"] == "q8_0"+ assert by_tag["0.8b-q8_0"]["context"] == "128K"+ assert by_tag["latest"]["quantization"] == ""+ assert by_tag["0.8b"]["quantization"] == ""+++ ("tag", "expected"),+ [+ ("27b-q4_K_M", "q4_K_M"),+ ("27b-mtp-q8_0", "q8_0"),+ ("35b-a3b-coding-mxfp8", "mxfp8"),+ ("2b-nvfp4", "nvfp4"),+ ("0.8b-mlx-bf16", "bf16"),+ ("7b-instruct-fp16", "fp16"),+ ("4b-iq2_xs", "iq2_xs"),+ ("27b", ""),+ ("latest", ""),+ ("cloud", ""),+ ],+)+def test_quantization_is_read_the_way_the_library_names_tags(tag: str, expected: str) -> None:+ markup = f'<a href="/library/x:{tag}">x</a> 1GB'+ assert library.parse_tags_html(markup, "x")[0]["quantization"] == expected+++def test_tags_parser_reads_a_namespaced_model_page() -> None:+ """Community models live at ``/{user}/{model}:{tag}`` — no ``/library/``+ prefix — and must parse with the same anchors."""+ page = (+ '<a href="/huihui_ai/qwen3-abliterated:latest">x</a> 5.2GB • 40K context window'+ " • Text input • 1 year ago"+ '<a href="/huihui_ai/qwen3-abliterated:0.6b-q8_0">x</a> 639MB'+ )+ tags = library.parse_tags_html(page, "huihui_ai/qwen3-abliterated")+ assert [t["id"] for t in tags] == [+ "huihui_ai/qwen3-abliterated:latest",+ "huihui_ai/qwen3-abliterated:0.6b-q8_0",+ ]+ assert tags[0]["context"] == "40K"+ assert tags[1]["quantization"] == "q8_0"++def test_tags_parser_flags_cloud_from_the_name_only(tags_page: str) -> None:"""Cloud is a NAME fact. A local tag whose size fails to parse must staysize-unknown, never become cloud-only."""@@ -126,9 +173,7 @@ def test_tags_parser_flags_cloud_from_the_name_only(tags_page: str) -> None:assert cloud["cloud"] is Trueassert cloud["size_gb"] is None- broken = library.parse_tags_html(- '<a href="/library/x:4b">x:4b</a> no size markers here', "x"- )+ broken = library.parse_tags_html('<a href="/library/x:4b">x:4b</a> no size markers here', "x")assert broken[0]["cloud"] is Falseassert broken[0]["size_gb"] is None@@ -136,11 +181,18 @@ def test_tags_parser_flags_cloud_from_the_name_only(tags_page: str) -> None:# ── async surfaces: degradation, enrichment, caching ─────────────────────-def _fake_fetch(page: str | None, error: str | None, calls: list[str]):+def _fake_fetch(+ page: str | None,+ error: str | None,+ calls: list[str],+ params_seen: list[dict[str, str] | None] | None = None,+):async def fetch(path: str, params: dict[str, str] | None = None) -> tuple[str | None, str | None]:calls.append(path)+ if params_seen is not None:+ params_seen.append(params)return page, errorreturn fetch@@ -168,6 +220,65 @@ async def test_search_marks_installed_models(monkeypatch, search_page: str, _macassert by_name["deepscaler"]["installed"] is False+ ("kwargs", "expected_params"),+ [+ ({}, {"q": "qwen"}),+ ({"sort": "popular"}, {"q": "qwen"}),+ ({"sort": "newest"}, {"q": "qwen", "o": "newest"}),+ ({"capability": "tools"}, {"q": "qwen", "c": "tools"}),+ ({"sort": "newest", "capability": "vision"}, {"q": "qwen", "o": "newest", "c": "vision"}),+ # Values the page does not know are dropped, never forwarded.+ ({"sort": "loudest", "capability": "magic"}, {"q": "qwen"}),+ ],+)+async def test_search_forwards_sort_and_capability_as_the_page_expects(+ monkeypatch, search_page: str, _machine, kwargs, expected_params+) -> None:+ seen: list[dict[str, str] | None] = []+ monkeypatch.setattr(library, "_fetch_page", _fake_fetch(search_page, None, [], seen))+ result = await library.search_library("qwen", **kwargs)+ assert seen == [expected_params]+ assert result["sort"] == expected_params.get("o", "popular")+ assert result["capability"] == expected_params.get("c")+++async def test_an_empty_newest_browse_sends_only_the_sort(+ monkeypatch, search_page: str, _machine+) -> None:+ seen: list[dict[str, str] | None] = []+ monkeypatch.setattr(library, "_fetch_page", _fake_fetch(search_page, None, [], seen))+ await library.search_library("", sort="newest")+ assert seen == [{"o": "newest"}]+++async def test_search_limit_trims_the_answer_not_the_cache(+ monkeypatch, search_page: str, _machine+) -> None:+ calls: list[str] = []+ monkeypatch.setattr(library, "_fetch_page", _fake_fetch(search_page, None, calls))+ short = await library.search_library("qwen", limit=1)+ assert len(short["models"]) == 1+ full = await library.search_library("qwen", limit=500)+ assert len(full["models"]) == 3+ assert len(calls) == 1+++async def test_search_caches_per_sort_and_filter(monkeypatch, search_page: str, _machine) -> None:+ """Newest and popular are different pages; one must not answer for the other."""+ calls: list[str] = []+ monkeypatch.setattr(library, "_fetch_page", _fake_fetch(search_page, None, calls))+ await library.search_library("qwen")+ await library.search_library("qwen", sort="newest")+ await library.search_library("qwen", capability="tools")+ await library.search_library("qwen", sort="newest")+ assert len(calls) == 3++@pytest.mark.asyncioasync def test_search_degrades_honestly_when_offline(monkeypatch, _machine) -> None:monkeypatch.setattr(@@ -234,9 +345,7 @@ async def test_a_freshly_pulled_tag_stops_offering_download_immediately(@pytest.mark.asyncio-async def test_search_installed_state_is_never_cached(- monkeypatch, search_page: str-) -> None:+async def test_search_installed_state_is_never_cached(monkeypatch, search_page: str) -> None:inventory: set[str] = set()async def _installed() -> tuple[set[str], str | None]:@@ -265,6 +374,30 @@ async def test_tags_reject_a_name_that_is_not_a_library_name(_machine) -> None:assert result["error"] == "Not a valid library model name."[email protected]("name", ["../evil", "a/../b", "a/b/c", ".hidden", "a?x", "a/.x"])+async def test_tags_reject_path_shaped_namespaces(_machine, name: str) -> None:+ result = await library.library_tags(name)+ assert result["tags"] == []+ assert result["error"] == "Not a valid library model name."+++async def test_tags_fetch_a_namespaced_model_from_its_own_path(monkeypatch, _machine) -> None:+ """``/library/{user}/{model}/tags`` answers 404 on ollama.com; a community+ model lives at ``/{user}/{model}/tags``."""+ calls: list[str] = []+ page = '<a href="/huihui_ai/qwen3-abliterated:latest">x</a> 5.2GB'+ monkeypatch.setattr(library, "_fetch_page", _fake_fetch(page, None, calls))+ result = await library.library_tags("huihui_ai/qwen3-abliterated")+ assert calls == ["/huihui_ai/qwen3-abliterated/tags"]+ assert result["error"] is None+ assert result["tags"][0]["id"] == "huihui_ai/qwen3-abliterated:latest"++ await library.library_tags("qwen3.5")+ assert calls[-1] == "/library/qwen3.5/tags"++@pytest.mark.asyncioasync def test_tags_error_when_the_page_stops_parsing(monkeypatch, _machine) -> None:"""A shape change upstream must surface as a sentence, not an empty listdiff --git a/tests/unit/brain/test_ollama_pull.py b/tests/unit/brain/test_ollama_pull.pyindex 1bdd9de41e..a18e57ad0b 100644--- a/tests/unit/brain/test_ollama_pull.py+++ b/tests/unit/brain/test_ollama_pull.py@@ -179,11 +179,14 @@ async def test_recommendations_mark_what_is_already_there(fake_tags) -> None:result = await pull.recommendations()by_id = {m["id"]: m for m in result["models"]}assert by_id["qwen3.5"]["installed"] is True- assert by_id["qwen3-vl"]["installed"] is False- # The vision entry must be findable AS the vision entry — it is the one- # that makes Screen Context work on a local-only install.- assert by_id["qwen3-vl"]["vision"] is True+ assert by_id["qwen3-vl:2b"]["installed"] is False+ # The vision fallback must be findable AS the vision entry — it is the one+ # that makes Screen Context work on a machine too small for a multimodal+ # chat pick, and the chat picks that see the screen say so themselves.+ assert by_id["qwen3-vl:2b"]["vision"] is True+ assert by_id["qwen3.5"]["vision"] is Trueassert result["server_reachable"] is True+ assert result["curated_reviewed_on"] == pull.CURATED_REVIEWED_ON.isoformat()async def test_recommendations_stay_usable_when_the_server_is_down(fake_tags) -> None:@@ -370,7 +373,9 @@ async def test_a_big_machine_is_recommended_a_big_model(fake_tags, monkeypatch)_machine(monkeypatch, ram=128.0, accel=80.0)result = await pull.recommendations()chat = [m for m in result["models"] if m["role"] == "chat"]- picked = [m for m in chat if m["recommended"]]+ # A second chat row may be flagged as the VISION pick; the chat role+ # itself still has exactly one answer.+ picked = [m for m in chat if "chat" in m["recommended_for"]]assert len(picked) == 1, "exactly one pick per role"# The largest chat model that still fits comfortably — on 80 GB that is the# top of the list, which is the entire point of probing the hardware.@@ -403,8 +408,39 @@ async def test_every_role_gets_its_own_pick(fake_tags, monkeypatch) -> None:decision and gets a separate answer."""_machine(monkeypatch, ram=64.0, accel=24.0)result = await pull.recommendations()- picked_roles = {m["role"] for m in result["models"] if m["recommended"]}+ picked_roles = {role for m in result["models"] for role in m["recommended_for"]}assert picked_roles == set(result["roles"])+ assert all(m["recommended"] == bool(m["recommended_for"]) for m in result["models"])+++async def test_the_vision_pick_is_the_multimodal_chat_model_where_it_fits(+ fake_tags, monkeypatch+) -> None:+ """Every current chat family sees images, so a machine that runs one is not+ told to download a second model just for the screen. The separate vision+ line is only the fallback below the smallest multimodal chat pick."""+ _machine(monkeypatch, ram=64.0, accel=24.0)+ result = await pull.recommendations()+ vision_pick = next(m for m in result["models"] if "vision" in m["recommended_for"])+ assert vision_pick["role"] == "chat"+ assert vision_pick["vision"] is True++ _machine(monkeypatch, ram=4.0, accel=0.0)+ result = await pull.recommendations()+ vision_pick = next(m for m in result["models"] if "vision" in m["recommended_for"])+ assert vision_pick["id"] == "qwen3-vl:2b"+++def test_the_shortlist_review_date_is_not_a_year_old() -> None:+ """The date the panel prints as "Shortlist reviewed …" must be true AND+ recent: a list nobody has checked for a year ships year-old defaults."""+ import datetime++ age = datetime.date.today() - pull.CURATED_REVIEWED_ON+ assert age.days <= pull.CURATED_MAX_AGE_DAYS, (+ f"The curated Ollama shortlist was last reviewed on {pull.CURATED_REVIEWED_ON}; "+ "check every tag against ollama.com and bump CURATED_REVIEWED_ON."+ )async def test_an_installed_role_stops_being_recommended(fake_tags, monkeypatch) -> None:@@ -415,8 +451,12 @@ async def test_an_installed_role_stops_being_recommended(fake_tags, monkeypatch)result = await pull.recommendations()chat = [m for m in result["models"] if m["role"] == "chat"]assert not any(m["recommended"] for m in chat)+ # The installed chat model sees the screen, so the vision role is served+ # too — recommending a separate vision download now would be nagging.+ assert not any("vision" in m["recommended_for"] for m in result["models"])# Other roles are untouched — one installed model does not silence the rest.- assert any(m["recommended"] for m in result["models"] if m["role"] == "vision")+ assert any(m["recommended"] for m in result["models"] if m["role"] == "coder")+ assert any(m["recommended"] for m in result["models"] if m["role"] == "embedding")async def test_real_registry_sizes_replace_the_estimates(fake_tags, monkeypatch) -> None: