@simplexai/localmodels-linux-x64 0.1.0-dev.55 → 0.1.0-dev.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/bootstrap.identity +1 -1
  2. package/bootstrap.sha256 +41 -36
  3. package/modules/localmodels/__init__.py +1 -1
  4. package/modules/localmodels/bifrost_admin.py +336 -0
  5. package/modules/localmodels/bifrost_checks.py +12 -2
  6. package/modules/localmodels/bifrost_config.py +13 -5
  7. package/modules/localmodels/catalog.json +2 -1
  8. package/modules/localmodels/engines.py +24 -1
  9. package/modules/localmodels/library_floor.py +3 -1
  10. package/modules/localmodels/library_gateway.py +26 -4
  11. package/modules/localmodels/library_jobs.py +44 -6
  12. package/modules/localmodels/library_kept.py +117 -0
  13. package/modules/localmodels/library_model.py +1 -0
  14. package/modules/localmodels/library_order.py +234 -0
  15. package/modules/localmodels/library_poly.py +20 -16
  16. package/modules/localmodels/library_pricing.py +8 -1
  17. package/modules/localmodels/library_serve.py +9 -3
  18. package/modules/localmodels/library_state.py +12 -2
  19. package/modules/localmodels/library_status.py +2 -0
  20. package/modules/localmodels/llm_rank.py +11 -8
  21. package/modules/localmodels/mirrors.py +464 -0
  22. package/modules/localmodels/recommend.py +2 -2
  23. package/modules/localmodels/records.py +1 -0
  24. package/modules/localmodels/region.py +457 -42
  25. package/modules/localmodels/remote_ops.py +130 -33
  26. package/modules/localmodels/remote_ops_download.py +313 -273
  27. package/modules/localmodels/remote_ops_mirrors.py +290 -0
  28. package/modules/localmodels/runtime-lock.json +19 -19
  29. package/modules/localmodels/runtime_io.py +2 -4
  30. package/modules/localmodels/setup_inspection.py +4 -0
  31. package/modules/localmodels/stack_auto.py +38 -5
  32. package/modules/localmodels/stack_compose.py +2 -1
  33. package/modules/localmodels/stack_try.py +4 -1
  34. package/modules/localmodels/transport.py +1 -0
  35. package/modules/{simplex_localmodels-0.1.0.dev55.dist-info → simplex_localmodels-0.1.0.dev56.dist-info}/METADATA +1 -1
  36. package/modules/{simplex_localmodels-0.1.0.dev55.dist-info → simplex_localmodels-0.1.0.dev56.dist-info}/RECORD +38 -33
  37. package/package.json +1 -1
  38. package/tool.json +1 -1
  39. /package/modules/{simplex_localmodels-0.1.0.dev55.dist-info → simplex_localmodels-0.1.0.dev56.dist-info}/WHEEL +0 -0
  40. /package/modules/{simplex_localmodels-0.1.0.dev55.dist-info → simplex_localmodels-0.1.0.dev56.dist-info}/entry_points.txt +0 -0
  41. /package/modules/{simplex_localmodels-0.1.0.dev55.dist-info → simplex_localmodels-0.1.0.dev56.dist-info}/licenses/NOTICE +0 -0
  42. /package/modules/{simplex_localmodels-0.1.0.dev55.dist-info → simplex_localmodels-0.1.0.dev56.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
@@ -0,0 +1,290 @@
1
+ #!/usr/bin/env python3
2
+ """Mirror prefix tables and URL classification for remote_ops downloads.
3
+
4
+ Part of the remote_ops bundle (transport.BUNDLES): standard library only, Python 3.8+.
5
+ """
6
+
7
+ from __future__ import annotations
8
+
9
+ import collections
10
+ import json
11
+ import os
12
+ import shutil
13
+ import tarfile
14
+ import time
15
+ import urllib.parse
16
+ import urllib.request
17
+
18
+ try:
19
+ from localmodels import remote_ops
20
+ except ImportError: # run as a bare file from this directory
21
+ import remote_ops # type: ignore[import-not-found,no-redef]
22
+
23
+ RATE_WINDOW_S = 10.0
24
+
25
+
26
+ class Rate:
27
+ """Bytes per second over the last ``window`` seconds of (time, bytes done) samples."""
28
+
29
+ def __init__(self, now: float, done: int, window: float | None = None) -> None:
30
+ self.window = RATE_WINDOW_S if window is None else window
31
+ self.samples: collections.deque[tuple[float, int]] = collections.deque([(now, done)])
32
+
33
+ def add(self, now: float, done: int) -> int:
34
+ while len(self.samples) > 1 and now - self.samples[1][0] >= self.window:
35
+ self.samples.popleft()
36
+ then, before = self.samples[0]
37
+ self.samples.append((now, done))
38
+ return int((done - before) / max(1e-3, now - then))
39
+
40
+
41
+ WEB: tuple[str, ...] = ("http", "https")
42
+ SOURCE_HOSTS: tuple[tuple[str, str], ...] = (
43
+ ("hf-mirror.com", "hf-mirror"),
44
+ ("huggingface.co", "huggingface"),
45
+ ("modelscope.cn", "modelscope"),
46
+ ("npmmirror.com", "npmmirror"),
47
+ ("pypi.tuna.tsinghua.edu.cn", "pypi-tsinghua"),
48
+ ("mirrors.tuna.tsinghua.edu.cn", "tsinghua"),
49
+ ("mirrors.aliyun.com", "aliyun"),
50
+ ("mirrors.ustc.edu.cn", "ustc"),
51
+ ("mirrors.cloud.tencent.com", "tencent"),
52
+ ("repo.huaweicloud.com", "huawei"),
53
+ ("files.pythonhosted.org", "pypi"),
54
+ )
55
+ # Which side of the network each host serves best. A host on neither (GitHub, a LAN registry,
56
+ # a user's own mirror) is neutral: it is never a reason to switch the region.
57
+ GLOBAL_HOSTS: tuple[str, ...] = (
58
+ "huggingface.co",
59
+ "registry.npmjs.org",
60
+ "nodejs.org",
61
+ "files.pythonhosted.org",
62
+ "pypi.org",
63
+ )
64
+ CN_HOSTS: tuple[str, ...] = (
65
+ "hf-mirror.com",
66
+ "modelscope.cn",
67
+ "npmmirror.com",
68
+ "tsinghua.edu.cn",
69
+ "mirrors.aliyun.com",
70
+ "mirrors.ustc.edu.cn",
71
+ "mirrors.cloud.tencent.com",
72
+ "repo.huaweicloud.com",
73
+ )
74
+ # Groups of equivalent URL prefixes serving byte-identical artifacts at the exact same subpath.
75
+ # Any URL matching one prefix in a group automatically gains all other prefixes as candidates.
76
+ MIRROR_GROUPS: tuple[tuple[str, ...], ...] = (
77
+ (
78
+ "https://huggingface.co/",
79
+ "https://hf-mirror.com/",
80
+ ),
81
+ (
82
+ "https://registry.npmjs.org/",
83
+ "https://registry.npmmirror.com/",
84
+ ),
85
+ (
86
+ "https://nodejs.org/dist/",
87
+ "https://cdn.npmmirror.com/binaries/node/",
88
+ "https://mirrors.tuna.tsinghua.edu.cn/nodejs-release/",
89
+ ),
90
+ (
91
+ "https://files.pythonhosted.org/packages/",
92
+ "https://pypi.tuna.tsinghua.edu.cn/packages/",
93
+ "https://mirrors.aliyun.com/pypi/packages/",
94
+ "https://mirrors.ustc.edu.cn/pypi/packages/",
95
+ "https://mirrors.cloud.tencent.com/pypi/packages/",
96
+ "https://repo.huaweicloud.com/repository/pypi/packages/",
97
+ ),
98
+ )
99
+ # Pairwise (global, primary_cn) view for backward-compatible inspection.
100
+ ALTERNATES: tuple[tuple[str, str], ...] = tuple((group[0], group[1]) for group in MIRROR_GROUPS)
101
+ NPM_REGISTRIES: tuple[tuple[str, str], ...] = (
102
+ ("npm", "https://registry.npmjs.org"),
103
+ ("npmmirror", "https://registry.npmmirror.com"),
104
+ )
105
+ # Tie-break order in region cn when two candidates measure the same throughput or are unprobed.
106
+ CN_RANK: dict[str, int] = {
107
+ "modelscope": 1,
108
+ "npmmirror": 1,
109
+ "pypi-tsinghua": 1,
110
+ "tsinghua": 1,
111
+ "aliyun": 1,
112
+ "ustc": 1,
113
+ "tencent": 1,
114
+ "huawei": 1,
115
+ "custom": 2,
116
+ "hf-mirror": 3,
117
+ }
118
+
119
+
120
+ def cn_rank(source: remote_ops.Source) -> int:
121
+ return 0 if remote_ops.non_public(source["url"]) else CN_RANK.get(source["source"], 4)
122
+
123
+
124
+ def _host_in(url: str, domains: tuple[str, ...]) -> bool:
125
+ host = (urllib.parse.urlsplit(url).hostname or "").lower()
126
+ return any(host == d or host.endswith("." + d) for d in domains)
127
+
128
+
129
+ def source_name(url: str) -> str:
130
+ """The public label of a download URL (never the full URL)."""
131
+ for domain, name in SOURCE_HOSTS:
132
+ if _host_in(url, (domain,)):
133
+ return name
134
+ return "custom"
135
+
136
+
137
+ def side(url: str) -> str:
138
+ """``cn``, ``global`` or "" (neutral) for a download URL."""
139
+ return "cn" if _host_in(url, CN_HOSTS) else "global" if _host_in(url, GLOBAL_HOSTS) else ""
140
+
141
+
142
+ def is_web(source: remote_ops.Source) -> bool:
143
+ return urllib.parse.urlsplit(source["url"]).scheme in WEB
144
+
145
+
146
+ def alternates(source: remote_ops.Source) -> list[remote_ops.Source]:
147
+ """Other hosts that serve byte-identical files at the same path."""
148
+ found: list[remote_ops.Source] = []
149
+ seen = {source["url"]}
150
+ for group in MIRROR_GROUPS:
151
+ for here in group:
152
+ if source["url"].startswith(here):
153
+ tail = source["url"][len(here) :]
154
+ for there in group:
155
+ if there == here:
156
+ continue
157
+ url = there + tail
158
+ if url in seen:
159
+ continue
160
+ seen.add(url)
161
+ other: remote_ops.Source = {"source": source_name(url), "url": url}
162
+ if source.get("member"):
163
+ other["member"] = source["member"]
164
+ found.append(other)
165
+ return found
166
+
167
+
168
+ def npm_copies(asset: remote_ops.Archive) -> list[remote_ops.Source]:
169
+ """The npm packages holding a byte-identical copy of ``asset`` (``npm_copy`` in the engine
170
+ and tool locks), on the npm registry and its China mirror; the copy is the package's file of
171
+ the asset's name, and its SHA256 pin is the asset's."""
172
+ copy = asset.get("npm_copy")
173
+ if not copy:
174
+ return []
175
+ name, version = copy["package"], copy["version"]
176
+ tail = f"{name}/-/{name.split('/')[-1]}-{version}.tgz"
177
+ return [
178
+ {"source": label, "url": f"{base}/{tail}", "member": "package/" + asset["name"]}
179
+ for label, base in NPM_REGISTRIES
180
+ ]
181
+
182
+
183
+ def candidates(
184
+ sources: list[remote_ops.Source], region: str | None
185
+ ) -> tuple[list[remote_ops.Source], list[remote_ops.Source]]:
186
+ """(the plan's own sources, the alternates added for the region), without duplicates."""
187
+ own: list[remote_ops.Source] = []
188
+ for s in sources:
189
+ if s.get("url") and all(s["url"] != o["url"] for o in own):
190
+ own.append(s)
191
+ extra: list[remote_ops.Source] = []
192
+ if region in ("cn", "global"):
193
+ for s in own:
194
+ for alt in alternates(s):
195
+ if all(alt["url"] != o["url"] for o in own + extra):
196
+ extra.append(alt)
197
+ return own, extra
198
+
199
+
200
+ NPM_OVERHEAD_BYTES = 4 << 20
201
+
202
+
203
+ def state_path(part: str) -> str:
204
+ return part + ".ranges"
205
+
206
+
207
+ def load_ranges(part: str, size: int) -> list[list[int]] | None:
208
+ try:
209
+ state = json.loads(remote_ops._read(state_path(part)))
210
+ segments = [[int(a), int(b), int(c)] for a, b, c in state["segments"]]
211
+ except (OSError, ValueError, KeyError, TypeError):
212
+ return None
213
+ if state.get("size") != size or not os.path.exists(part) or os.path.getsize(part) != size:
214
+ return None
215
+ if any(not 0 <= start <= done <= end <= size for start, end, done in segments):
216
+ return None
217
+ return segments
218
+
219
+
220
+ def save_ranges(part: str, size: int, segments: list[list[int]]) -> None:
221
+ path = state_path(part)
222
+ remote_ops._write(path + ".tmp", json.dumps({"size": size, "segments": segments}))
223
+ os.replace(path + ".tmp", path)
224
+
225
+
226
+ def kept_bytes(part: str, size: int) -> int:
227
+ """Bytes of ``part`` already downloaded: its ranges record when it has one, else its size."""
228
+ segments = load_ranges(part, size)
229
+ if segments is not None:
230
+ return size - sum(end - done for _, end, done in segments)
231
+ return os.path.getsize(part) if os.path.exists(part) else 0
232
+
233
+
234
+ def discard(part: str) -> None:
235
+ for path in (part, state_path(part)):
236
+ if os.path.exists(path):
237
+ os.remove(path)
238
+
239
+
240
+ def npm_transfer(
241
+ source: remote_ops.Source,
242
+ part: str,
243
+ size: int,
244
+ label: str,
245
+ *,
246
+ overhead: int | None = None,
247
+ ) -> None:
248
+ """Fill ``part`` with the ``member`` file of the npm package at ``source``: the package is
249
+ read in one bounded stream, then only that regular file of exactly ``size`` bytes is taken.
250
+ The caller checks its SHA256 against the asset's pin as for any other source."""
251
+ archive = part + ".npm"
252
+ cap = size + size // 64 + (NPM_OVERHEAD_BYTES if overhead is None else overhead)
253
+ request = urllib.request.Request(source["url"], headers={"User-Agent": "localmodels-deploy"})
254
+ got, start, mark = 0, time.monotonic(), time.monotonic()
255
+ try:
256
+ with urllib.request.urlopen(request, timeout=60) as r, open(archive, "wb") as out:
257
+ while True:
258
+ chunk = r.read(remote_ops._CHUNK)
259
+ if not chunk:
260
+ break
261
+ got += len(chunk)
262
+ if got > cap:
263
+ raise RuntimeError(f"the npm copy of {label} exceeds its size limit")
264
+ out.write(chunk)
265
+ if time.monotonic() - mark >= remote_ops._PROGRESS_EVERY_S:
266
+ mark = time.monotonic()
267
+ remote_ops.emit(
268
+ "progress",
269
+ phase="download",
270
+ file=label,
271
+ done=min(got, size),
272
+ total=size,
273
+ bytes_per_s=int(got / max(1e-3, mark - start)),
274
+ source=source["source"],
275
+ connections=1,
276
+ **remote_ops.step_fields(min(got, size)),
277
+ )
278
+ with tarfile.open(archive) as tar:
279
+ member = tar.getmember(source["member"])
280
+ stream = tar.extractfile(member) if member.isfile() and member.size == size else None
281
+ if stream is None:
282
+ raise RuntimeError(f"the npm copy of {label} does not hold a {size}-byte file")
283
+ discard(state_path(part)) # part is rewritten whole, not resumed
284
+ with stream, open(part, "wb") as out:
285
+ shutil.copyfileobj(stream, out, remote_ops._CHUNK)
286
+ except KeyError:
287
+ raise RuntimeError(f"the npm copy of {label} does not hold {source['member']}") from None
288
+ finally:
289
+ if os.path.exists(archive):
290
+ os.remove(archive)
@@ -2,7 +2,7 @@
2
2
  "schema": "localmodels.runtime-lock/v1",
3
3
  "versions": {
4
4
  "codex": "0.171.0",
5
- "claude": "2.1.311"
5
+ "claude": "2.1.325"
6
6
  },
7
7
  "baselines": {
8
8
  "codex": "0.166.0",
@@ -62,60 +62,60 @@
62
62
  ],
63
63
  "claude/win32-arm64": [
64
64
  {
65
- "url": "https://downloads.claude.ai/claude-code-releases/2.1.311/win32-arm64/claude.exe",
65
+ "url": "https://downloads.claude.ai/claude-code-releases/2.1.325/win32-arm64/claude.exe",
66
66
  "algorithm": "sha256",
67
- "digest": "951b5d94bf2a5296db2c442784e68d18fa04dec2d7d2e805aa50e75d618aad5e",
68
- "maxBytes": 419430400,
67
+ "digest": "45c1d546a0048dcdde3433ada6c10f7f23bd71a96868b9d75e28f1ac266f1a25",
68
+ "maxBytes": 354470048,
69
69
  "format": "binary",
70
70
  "executable": "claude.exe"
71
71
  }
72
72
  ],
73
73
  "claude/win32-x64": [
74
74
  {
75
- "url": "https://downloads.claude.ai/claude-code-releases/2.1.311/win32-x64/claude.exe",
75
+ "url": "https://downloads.claude.ai/claude-code-releases/2.1.325/win32-x64/claude.exe",
76
76
  "algorithm": "sha256",
77
- "digest": "966f4b2ce962298f5dee6a942e8c47c8f97392e69e728e622319a98b259c0680",
78
- "maxBytes": 419430400,
77
+ "digest": "87e0cb6ae0f4775da388cd3043f4d8097ef961dcddbf55fe90bc61ffc3f57a30",
78
+ "maxBytes": 372461728,
79
79
  "format": "binary",
80
80
  "executable": "claude.exe"
81
81
  }
82
82
  ],
83
83
  "claude/darwin-arm64": [
84
84
  {
85
- "url": "https://downloads.claude.ai/claude-code-releases/2.1.311/darwin-arm64/claude",
85
+ "url": "https://downloads.claude.ai/claude-code-releases/2.1.325/darwin-arm64/claude",
86
86
  "algorithm": "sha256",
87
- "digest": "85d8c08707fcfd1e78ffa0204eefbc6ec9e4fe22f375fb2767ef85d957ed3161",
88
- "maxBytes": 419430400,
87
+ "digest": "84590fefe6338be9087f5814b61f9a54c5f21524163a4c127cb5a808e31009f2",
88
+ "maxBytes": 347406976,
89
89
  "format": "binary",
90
90
  "executable": "claude"
91
91
  }
92
92
  ],
93
93
  "claude/darwin-x64": [
94
94
  {
95
- "url": "https://downloads.claude.ai/claude-code-releases/2.1.311/darwin-x64/claude",
95
+ "url": "https://downloads.claude.ai/claude-code-releases/2.1.325/darwin-x64/claude",
96
96
  "algorithm": "sha256",
97
- "digest": "d34e1cb82015b050471a97574aa6ea6f698ecf3a97a61c980961f43ad9f838f5",
98
- "maxBytes": 419430400,
97
+ "digest": "af9760c59f947044e2a0d5072343de563f31efb68bd18ccee4f43c5240570de7",
98
+ "maxBytes": 362162560,
99
99
  "format": "binary",
100
100
  "executable": "claude"
101
101
  }
102
102
  ],
103
103
  "claude/linux-arm64": [
104
104
  {
105
- "url": "https://downloads.claude.ai/claude-code-releases/2.1.311/linux-arm64/claude",
105
+ "url": "https://downloads.claude.ai/claude-code-releases/2.1.325/linux-arm64/claude",
106
106
  "algorithm": "sha256",
107
- "digest": "2e2496c9a8065df93acb0fca2d341f59a6b8777649b2e025ab8c9bcd5eef61f3",
108
- "maxBytes": 419430400,
107
+ "digest": "7b6e484b1989a5a14a4b354709ccc8672518a3ec5b9ccd7981fc6254327fde67",
108
+ "maxBytes": 364701112,
109
109
  "format": "binary",
110
110
  "executable": "claude"
111
111
  }
112
112
  ],
113
113
  "claude/linux-x64": [
114
114
  {
115
- "url": "https://downloads.claude.ai/claude-code-releases/2.1.311/linux-x64/claude",
115
+ "url": "https://downloads.claude.ai/claude-code-releases/2.1.325/linux-x64/claude",
116
116
  "algorithm": "sha256",
117
- "digest": "86dc1fcc69498159eaf15f446613e847010f9036bfbbdffd4c49350be8489ada",
118
- "maxBytes": 419430400,
117
+ "digest": "0dc4f4a9a165fc60746d7ae8489712e5fc352f1e7ad4eb22e7141bd0812eb0cf",
118
+ "maxBytes": 365842960,
119
119
  "format": "binary",
120
120
  "executable": "claude"
121
121
  }
@@ -422,15 +422,13 @@ def _interrupted(exc: BaseException) -> _TransferError:
422
422
 
423
423
 
424
424
  def download_urls(url: str) -> list[str]:
425
- """``url`` and the other hosts serving the same file (the npm mirror for the npm registry
426
- and nodejs.org), in the download region's order. A URL with no other host does not resolve
427
- the region."""
425
+ """``url`` and alternate hosts serving the same file, ordered by region and cached speed."""
428
426
  source: remote_ops.Source = {"source": "", "url": url}
429
427
  every = [url, *(s["url"] for s in remote_ops_download.alternates(source))]
430
428
  if len(every) == 1:
431
429
  return every
432
430
  cn = [u for u in every if remote_ops_download.side(u) == "cn"]
433
- return region.prefer(region.current_region(), [u for u in every if u not in cn], cn)
431
+ return region.order_urls_for_region(url, [u for u in every if u not in cn], cn)
434
432
 
435
433
 
436
434
  def _host(url: str) -> str:
@@ -52,6 +52,7 @@ class _ReasonSince014(TypedDict, total=False):
52
52
  # On cuda-driver-update-required and cuda-driver-version-unknown: driver and CUDA versions.
53
53
  detectedCudaVersion: str
54
54
  requiredCudaVersion: str
55
+ requiredDriverVersion: str
55
56
  driverVersion: str
56
57
 
57
58
 
@@ -114,6 +115,7 @@ def _plan_reason(error: PlanError | StackError) -> Reason:
114
115
  def _cuda_driver_reason(error: CudaDriverError, lang: Lang) -> Reason:
115
116
  detected = error.detected_cuda if _VERSION_RE.fullmatch(error.detected_cuda) else ""
116
117
  required = error.required_cuda if _VERSION_RE.fullmatch(error.required_cuda) else ""
118
+ required_driver = error.required_driver if _VERSION_RE.fullmatch(error.required_driver) else ""
117
119
  driver = error.driver_version if _VERSION_RE.fullmatch(error.driver_version) else ""
118
120
  if detected:
119
121
  reason: Reason = {
@@ -137,6 +139,8 @@ def _cuda_driver_reason(error: CudaDriverError, lang: Lang) -> Reason:
137
139
  }
138
140
  if required:
139
141
  reason["requiredCudaVersion"] = required
142
+ if required_driver:
143
+ reason["requiredDriverVersion"] = required_driver
140
144
  if driver:
141
145
  reason["driverVersion"] = driver
142
146
  return reason
@@ -25,6 +25,7 @@ from localmodels import (
25
25
  stack_ports,
26
26
  stack_suite,
27
27
  stack_warm_store,
28
+ suite,
28
29
  )
29
30
  from localmodels import stack_aux_gpu as aux_gpu
30
31
  from localmodels import stack_decision as decide
@@ -69,20 +70,37 @@ def strata_parts(
69
70
  owned_ram: Callable[[], int],
70
71
  passed_over: list[str],
71
72
  check: Callable[[Parts, StackOptions], None] | None = None,
73
+ approved: StackPlan | None = None,
72
74
  ) -> Parts | None:
73
75
  """The best validated Strata recipe whose installed SimplexAI score beats the llama.cpp
74
76
  pick by at least llm_rank.TIE_BAND and that fits this host, priced as if ``--llm`` named
75
77
  it (roadmap decisions 26 and 33: Strata keeps the experts in RAM, so a 24 GB card with 64 GB runs
76
78
  Flash-Next). None leaves the choice to llama.cpp; why each better recipe was passed over is
77
- added to ``passed_over`` for the llama.cpp plan's warnings."""
79
+ added to ``passed_over`` for the llama.cpp plan's warnings.
80
+
81
+ Rebuilding an ``approved`` plan tries its Strata recipe first and keeps it while it still
82
+ fits this computer, whatever the ranking says now: more memory free than at plan time, or a
83
+ newer kit that ranks or admits recipes differently, does not replace the LLM the operator
84
+ approved (o17, Linger 0.1.8: q2 approved on 15.6 GB free, q3 picked on 17.9 GB, every resume
85
+ refused). A recipe that no longer fits falls through to the ranking, and apply refuses the
86
+ changed plan."""
78
87
  bar, llama_id = llama
79
88
  skipped: list[str] = []
80
- for recipe in stack_suite.auto_strata_candidates(
89
+ ranked = stack_suite.auto_strata_candidates(
81
90
  facts, llm_rank.strata_bar(bar, options), llama_score=bar, options=options
82
- ):
83
- score = recipe["quality"]["score"]
91
+ )
92
+ kept = approved_strata_recipe(facts, approved)
93
+ if kept is not None:
94
+ ranked = [kept, *(r for r in ranked if r["id"] != kept["id"])]
95
+ for recipe in ranked:
96
+ score = recipe.get("quality", {}).get("score")
84
97
  why = (
85
- f"LLM: auto picks Strata {recipe['id']} (installed SimplexAI score {score}"
98
+ (
99
+ f"LLM: auto keeps the approved Strata {recipe['id']}"
100
+ if kept is not None and recipe["id"] == kept["id"]
101
+ else f"LLM: auto picks Strata {recipe['id']}"
102
+ )
103
+ + f" (installed SimplexAI score {score}"
86
104
  + (
87
105
  f", best llama.cpp {llama_id} scores {bar}"
88
106
  if llama_id
@@ -100,6 +118,7 @@ def strata_parts(
100
118
  listening=listening,
101
119
  previous=previous,
102
120
  owned_ram=owned_ram,
121
+ approved=approved,
103
122
  )
104
123
  missing = [
105
124
  f for f in parts["llm"]["files"] if f.get("generated") and not preparation.ready(f)
@@ -436,6 +455,20 @@ def auto_llama_fits(
436
455
  return fitting, fallback_ids, bool(ram_refused)
437
456
 
438
457
 
458
+ def approved_strata_recipe(
459
+ facts: HostFacts, approved: StackPlan | None
460
+ ) -> suite.SuiteRecipe | None:
461
+ """The Strata recipe an approved ``--llm auto`` plan runs, when this kit still has it and
462
+ an engine build for this computer; None for a llama.cpp plan or a recipe that is gone."""
463
+ if approved is None:
464
+ return None
465
+ llm_id = approved["llm"]["model"]["id"]
466
+ recipe = stack_suite.strata_recipe(facts, llm_id)[0] if llm_id else None
467
+ if recipe is None or not stack_suite.built_for(recipe, facts["platform"]):
468
+ return None
469
+ return recipe
470
+
471
+
439
472
  def approved_keeps_llama(facts: HostFacts, approved: StackPlan | None) -> bool:
440
473
  """True when rebuilding an approved auto llama.cpp plan (never flip to Strata on rebuild)."""
441
474
  if approved is None:
@@ -261,6 +261,7 @@ def choose_parts(
261
261
  owned_ram,
262
262
  passed_over,
263
263
  check=check_strata,
264
+ approved=approved,
264
265
  )
265
266
  if parts is None:
266
267
  reads = (resolver, listening, previous, existing, owned_ram)
@@ -396,7 +397,7 @@ def _llm_warnings(
396
397
  warnings.append(f"LLM: {llm_rank.WINDOWS_FALLBACK_WARNING}")
397
398
  if llm_id in getattr(llm_rank.mac_ladder(facts), "smartest", ()) and options["llm"] == "auto":
398
399
  warnings.append(
399
- f"LLM: {llm_id} is on the user-selected Mac small-memory ladder (decision 57, 64K x 2);"
400
+ f"LLM: {llm_id} is on the user-selected Mac small-memory ladder (decisions 57, 68);"
400
401
  " no SimplexAI score, physical 16 GB install and full product acceptance pending"
401
402
  )
402
403
  if options["conversation_cache"] not in ("auto", "off"):
@@ -291,7 +291,10 @@ def _candidate_log_row(
291
291
  if row.get("provider") not in (gateway_bifrost.FAST_PROVIDER, llm_provider):
292
292
  return False
293
293
  rule = row.get("routing_rule_id")
294
- if rule not in (None, "", gateway_bifrost.COMPLEX_RULE, gateway_bifrost.AGENT_RULE):
294
+ rule_name = row.get("routing_rule_name")
295
+ if rule not in (None, "", gateway_bifrost.COMPLEX_RULE, gateway_bifrost.AGENT_RULE) and (
296
+ rule_name not in (gateway_bifrost.COMPLEX_RULE, gateway_bifrost.AGENT_RULE)
297
+ ):
295
298
  return False
296
299
  if json.dumps(row, sort_keys=True) in before_logs:
297
300
  return False
@@ -48,6 +48,7 @@ BUNDLES = {
48
48
  "process_identity_darwin.py",
49
49
  "process_identity_linux.py",
50
50
  "remote_ops_download.py",
51
+ "remote_ops_mirrors.py",
51
52
  "remote_ops_prepare.py",
52
53
  "remote_ops_service.py",
53
54
  "remote_ops_verify.py",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: simplex-localmodels
3
- Version: 0.1.0.dev55
3
+ Version: 0.1.0.dev56
4
4
  Summary: Detect hardware, recommend and install a verified local model stack
5
5
  License-Expression: LicenseRef-Proprietary
6
6
  License-File: NOTICE