@simplexai/localmodels-linux-x64 0.1.0-dev.55 → 0.1.0-dev.57
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.
- package/bootstrap.identity +1 -1
- package/bootstrap.sha256 +61 -55
- package/modules/localmodels/__init__.py +1 -1
- package/modules/localmodels/bifrost_admin.py +337 -0
- package/modules/localmodels/bifrost_checks.py +23 -10
- package/modules/localmodels/bifrost_config.py +13 -5
- package/modules/localmodels/bifrost_models.py +2 -1
- package/modules/localmodels/catalog.json +12 -9
- package/modules/localmodels/engines.py +24 -1
- package/modules/localmodels/gateway_accept.py +4 -3
- package/modules/localmodels/gateway_bifrost.py +2 -1
- package/modules/localmodels/gateway_cli.py +4 -3
- package/modules/localmodels/gateway_server.py +3 -1
- package/modules/localmodels/harness.py +2 -2
- package/modules/localmodels/hf_repo.py +27 -4
- package/modules/localmodels/library_floor.py +3 -1
- package/modules/localmodels/library_gateway.py +26 -4
- package/modules/localmodels/library_jobs.py +44 -6
- package/modules/localmodels/library_kept.py +117 -0
- package/modules/localmodels/library_model.py +1 -0
- package/modules/localmodels/library_order.py +234 -0
- package/modules/localmodels/library_poly.py +20 -16
- package/modules/localmodels/library_pricing.py +8 -1
- package/modules/localmodels/library_serve.py +9 -3
- package/modules/localmodels/library_state.py +12 -2
- package/modules/localmodels/library_status.py +2 -0
- package/modules/localmodels/llm_rank.py +11 -8
- package/modules/localmodels/mirrors.py +464 -0
- package/modules/localmodels/recommend.py +2 -2
- package/modules/localmodels/records.py +1 -0
- package/modules/localmodels/region.py +457 -42
- package/modules/localmodels/remote_ops.py +130 -33
- package/modules/localmodels/remote_ops_download.py +233 -418
- package/modules/localmodels/remote_ops_mirrors.py +290 -0
- package/modules/localmodels/remote_ops_ranges.py +447 -0
- package/modules/localmodels/runtime-lock.json +19 -19
- package/modules/localmodels/runtime_auth.py +2 -1
- package/modules/localmodels/runtime_cli.py +1 -1
- package/modules/localmodels/runtime_install.py +5 -2
- package/modules/localmodels/runtime_io.py +5 -6
- package/modules/localmodels/runtime_pi.py +2 -1
- package/modules/localmodels/runtime_windows_acl.py +39 -0
- package/modules/localmodels/setup_inspection.py +4 -0
- package/modules/localmodels/source_byok_probe.py +2 -1
- package/modules/localmodels/stack.py +13 -3
- package/modules/localmodels/stack_auto.py +38 -5
- package/modules/localmodels/stack_cli.py +1 -0
- package/modules/localmodels/stack_compose.py +2 -1
- package/modules/localmodels/stack_events.py +15 -0
- package/modules/localmodels/stack_plan.py +5 -1
- package/modules/localmodels/stack_progress.py +30 -5
- package/modules/localmodels/stack_run.py +117 -0
- package/modules/localmodels/stack_try.py +4 -1
- package/modules/localmodels/transport.py +2 -0
- package/modules/{simplex_localmodels-0.1.0.dev55.dist-info → simplex_localmodels-0.1.0.dev57.dist-info}/METADATA +1 -1
- package/modules/{simplex_localmodels-0.1.0.dev55.dist-info → simplex_localmodels-0.1.0.dev57.dist-info}/RECORD +58 -52
- package/package.json +1 -1
- package/tool.json +1 -1
- /package/modules/{simplex_localmodels-0.1.0.dev55.dist-info → simplex_localmodels-0.1.0.dev57.dist-info}/WHEEL +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev55.dist-info → simplex_localmodels-0.1.0.dev57.dist-info}/entry_points.txt +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev55.dist-info → simplex_localmodels-0.1.0.dev57.dist-info}/licenses/NOTICE +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev55.dist-info → simplex_localmodels-0.1.0.dev57.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
|
@@ -2,8 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
+
import errno
|
|
5
6
|
import functools
|
|
6
7
|
import os
|
|
8
|
+
import sys
|
|
9
|
+
import time
|
|
10
|
+
from collections.abc import Callable, Sequence
|
|
7
11
|
from pathlib import Path
|
|
8
12
|
from typing import Any
|
|
9
13
|
|
|
@@ -294,3 +298,38 @@ def protect(advapi: Any, kernel: Any, path: Path, user_sid: str) -> None:
|
|
|
294
298
|
finally:
|
|
295
299
|
if security.value:
|
|
296
300
|
kernel.LocalFree(security)
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
_WINDOWS_RENAME_RETRY_WINERRORS = frozenset({5, 32})
|
|
304
|
+
_WINDOWS_RENAME_RETRY_DELAYS_S = (0.05, 0.1, 0.2, 0.4, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5)
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
def _retryable_windows_rename_error(exc: OSError) -> bool:
|
|
308
|
+
"""True for transient Windows Defender / Search Indexer handle locks on newly written files."""
|
|
309
|
+
if sys.platform != "win32" or not isinstance(exc, PermissionError):
|
|
310
|
+
return False
|
|
311
|
+
winerror = getattr(exc, "winerror", None)
|
|
312
|
+
if winerror is not None:
|
|
313
|
+
return winerror in _WINDOWS_RENAME_RETRY_WINERRORS
|
|
314
|
+
return exc.errno in (None, errno.EACCES)
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
def rename_with_retry(
|
|
318
|
+
source: Path,
|
|
319
|
+
target: Path,
|
|
320
|
+
*,
|
|
321
|
+
replace: bool = False,
|
|
322
|
+
delays: Sequence[float] = _WINDOWS_RENAME_RETRY_DELAYS_S,
|
|
323
|
+
pause: Callable[[float], None] | None = None,
|
|
324
|
+
) -> Path:
|
|
325
|
+
"""Rename or replace ``source`` into ``target``, retrying transient Windows AV locks
|
|
326
|
+
(WinError 5 Access Denied / WinError 32 Sharing Violation) with bounded backoff."""
|
|
327
|
+
sleep = time.sleep if pause is None else pause
|
|
328
|
+
for delay in delays:
|
|
329
|
+
try:
|
|
330
|
+
return source.replace(target) if replace else source.rename(target)
|
|
331
|
+
except OSError as exc:
|
|
332
|
+
if not _retryable_windows_rename_error(exc):
|
|
333
|
+
raise
|
|
334
|
+
sleep(delay)
|
|
335
|
+
return source.replace(target) if replace else source.rename(target)
|
|
@@ -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
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
+
import http.client
|
|
5
6
|
import json
|
|
6
7
|
import time
|
|
7
8
|
import urllib.error
|
|
@@ -83,7 +84,7 @@ def _call(
|
|
|
83
84
|
f"{url} returned HTTP 404: the address or the model was not found.",
|
|
84
85
|
) from None
|
|
85
86
|
raise ByokError("BYOK_UPSTREAM_REJECTED", f"{url} returned HTTP {exc.code}.") from None
|
|
86
|
-
except (urllib.error.URLError, TimeoutError, OSError) as exc:
|
|
87
|
+
except (urllib.error.URLError, TimeoutError, OSError, http.client.HTTPException) as exc:
|
|
87
88
|
raise ByokError(
|
|
88
89
|
"BYOK_UNREACHABLE", f"Could not reach {url} ({type(exc).__name__})."
|
|
89
90
|
) from None
|
|
@@ -199,7 +199,8 @@ def _deploy(component: str, plan: Plan, key: str, log: Log) -> Component:
|
|
|
199
199
|
)
|
|
200
200
|
if record["ok"]:
|
|
201
201
|
return _ok(component, f"{plan['endpoint']['base_url']} ({plan['service']['name']})")
|
|
202
|
-
|
|
202
|
+
failed_step = record["steps"][-1]["step"] if record["steps"] else None
|
|
203
|
+
return _failed(component, record.get("error", "unknown failure"), step=failed_step)
|
|
203
204
|
|
|
204
205
|
|
|
205
206
|
@dataclass(frozen=True)
|
|
@@ -229,13 +230,22 @@ def _ok(component: str, detail: str, checks: list[gateway.Check] | None = None)
|
|
|
229
230
|
return {"component": component, "status": "ok", "detail": detail, "checks": checks or []}
|
|
230
231
|
|
|
231
232
|
|
|
232
|
-
def _failed(
|
|
233
|
-
|
|
233
|
+
def _failed(
|
|
234
|
+
component: str,
|
|
235
|
+
detail: str,
|
|
236
|
+
checks: list[gateway.Check] | None = None,
|
|
237
|
+
*,
|
|
238
|
+
step: str | None = None,
|
|
239
|
+
) -> Component:
|
|
240
|
+
failed: Component = {
|
|
234
241
|
"component": component,
|
|
235
242
|
"status": "failed",
|
|
236
243
|
"detail": detail[-600:],
|
|
237
244
|
"checks": checks or [],
|
|
238
245
|
}
|
|
246
|
+
if step:
|
|
247
|
+
failed["step"] = step
|
|
248
|
+
return failed
|
|
239
249
|
|
|
240
250
|
|
|
241
251
|
# Apply re-plans an approved plan from this computer's state and refuses one that changed. A busy
|
|
@@ -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
|
-
|
|
89
|
+
ranked = stack_suite.auto_strata_candidates(
|
|
81
90
|
facts, llm_rank.strata_bar(bar, options), llama_score=bar, options=options
|
|
82
|
-
)
|
|
83
|
-
|
|
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
|
-
|
|
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:
|
|
@@ -208,6 +208,7 @@ def apply_cli(
|
|
|
208
208
|
((c["component"], c["status"]) for c in record["components"]),
|
|
209
209
|
profile=record.get("profile"),
|
|
210
210
|
cause=failure[1][0] if failure else None,
|
|
211
|
+
reasons=stack_run.component_reasons(record) if failure else None,
|
|
211
212
|
)
|
|
212
213
|
return report(record, timing=shown.timing() if shown else None)
|
|
213
214
|
|
|
@@ -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 (
|
|
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"):
|
|
@@ -52,6 +52,21 @@ COMPONENTS = frozenset(
|
|
|
52
52
|
)
|
|
53
53
|
STEPS = frozenset({"engine", "download", "install", "start", "verify"})
|
|
54
54
|
PHASES = frozenset({"download", "verify", "loading"})
|
|
55
|
+
# Safe, closed-set public sub-reasons for a failing stack component (WHI-1002):
|
|
56
|
+
# never raw stderr, paths, hostnames, or exception text.
|
|
57
|
+
COMPONENT_REASON_CODES = frozenset(
|
|
58
|
+
{
|
|
59
|
+
"CHECKSUM_MISMATCH",
|
|
60
|
+
"DISK_FULL",
|
|
61
|
+
"OUT_OF_MEMORY",
|
|
62
|
+
"HEALTH_TIMEOUT",
|
|
63
|
+
"PORT_IN_USE",
|
|
64
|
+
"PERMISSION_DENIED",
|
|
65
|
+
"DOWNLOAD_FAILED",
|
|
66
|
+
"ENGINE_START_FAILED",
|
|
67
|
+
"ACCEPTANCE_FAILED",
|
|
68
|
+
}
|
|
69
|
+
)
|
|
55
70
|
|
|
56
71
|
|
|
57
72
|
SOURCES = frozenset({"huggingface", "modelscope", "custom"})
|
|
@@ -382,7 +382,11 @@ class Parts(_RouteParts):
|
|
|
382
382
|
warnings: list[str]
|
|
383
383
|
|
|
384
384
|
|
|
385
|
-
class
|
|
385
|
+
class _ComponentOptional(TypedDict, total=False):
|
|
386
|
+
step: str # failed deploy step (engine | download | install | start | verify)
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
class Component(_ComponentOptional):
|
|
386
390
|
component: str
|
|
387
391
|
status: str # ok | failed | skipped
|
|
388
392
|
detail: str
|
|
@@ -6,7 +6,13 @@ import json
|
|
|
6
6
|
from collections.abc import Iterable, Mapping
|
|
7
7
|
from typing import TextIO
|
|
8
8
|
|
|
9
|
-
from localmodels.stack_events import
|
|
9
|
+
from localmodels.stack_events import (
|
|
10
|
+
COMPONENT_REASON_CODES,
|
|
11
|
+
STACK_PLAN_SECTIONS,
|
|
12
|
+
ProgressObserver,
|
|
13
|
+
PublicProgress,
|
|
14
|
+
forward,
|
|
15
|
+
)
|
|
10
16
|
|
|
11
17
|
__all__ = ["JsonlObserver", "ProgressObserver", "PublicProgress", "forward", "result", "error"]
|
|
12
18
|
|
|
@@ -32,17 +38,36 @@ def result(
|
|
|
32
38
|
*,
|
|
33
39
|
profile: str | None = None,
|
|
34
40
|
cause: str | None = None,
|
|
41
|
+
reasons: Mapping[str, str] | None = None,
|
|
35
42
|
) -> int:
|
|
36
|
-
"""The final JSONL line; ``cause`` is the fixed public code of a run that did not pass
|
|
43
|
+
"""The final JSONL line; ``cause`` is the fixed public code of a run that did not pass, and
|
|
44
|
+
``reasons`` maps failed components to validated codes in ``COMPONENT_REASON_CODES``."""
|
|
45
|
+
safe_reasons = (
|
|
46
|
+
{
|
|
47
|
+
name: code
|
|
48
|
+
for name, code in reasons.items()
|
|
49
|
+
if isinstance(code, str) and code in COMPONENT_REASON_CODES
|
|
50
|
+
}
|
|
51
|
+
if not ok and reasons
|
|
52
|
+
else {}
|
|
53
|
+
)
|
|
54
|
+
rows = []
|
|
55
|
+
first_reason: str | None = None
|
|
56
|
+
for component, status in components:
|
|
57
|
+
row: dict[str, str] = {"component": component, "status": status}
|
|
58
|
+
if not ok and status == "failed" and (reason := safe_reasons.get(component)):
|
|
59
|
+
row["reasonCode"] = reason
|
|
60
|
+
if first_reason is None:
|
|
61
|
+
first_reason = reason
|
|
62
|
+
rows.append(row)
|
|
37
63
|
print(
|
|
38
64
|
json.dumps(
|
|
39
65
|
{
|
|
40
66
|
"event": "result",
|
|
41
67
|
"ok": ok,
|
|
42
|
-
"components":
|
|
43
|
-
{"component": component, "status": status} for component, status in components
|
|
44
|
-
],
|
|
68
|
+
"components": rows,
|
|
45
69
|
**({"causeCode": cause} if cause is not None and not ok else {}),
|
|
70
|
+
**({"reasonCode": first_reason} if first_reason is not None and not ok else {}),
|
|
46
71
|
**(
|
|
47
72
|
{"profile": "macos-mlx-preview", "product_acceptance": "incomplete"}
|
|
48
73
|
if profile == "macos-mlx-preview"
|
|
@@ -16,6 +16,7 @@ from localmodels.approval import digest
|
|
|
16
16
|
from localmodels.contracts import decode
|
|
17
17
|
from localmodels.plan_envelope import utc_now
|
|
18
18
|
from localmodels.records import FinishedRecord
|
|
19
|
+
from localmodels.stack_events import COMPONENT_REASON_CODES as COMPONENT_REASON_CODES
|
|
19
20
|
from localmodels.stack_events import COMPONENTS
|
|
20
21
|
from localmodels.stack_plan import (
|
|
21
22
|
Component,
|
|
@@ -445,6 +446,113 @@ CAUSES = {
|
|
|
445
446
|
}
|
|
446
447
|
|
|
447
448
|
|
|
449
|
+
_REASON_PATTERNS: tuple[tuple[str, tuple[str, ...]], ...] = (
|
|
450
|
+
(
|
|
451
|
+
"CHECKSUM_MISMATCH",
|
|
452
|
+
("sha256 mismatch", "checksum", "size mismatch", "digest mismatch", "pinned digest"),
|
|
453
|
+
),
|
|
454
|
+
("DISK_FULL", ("low disk space", "no space left", "enospc", "disk full")),
|
|
455
|
+
(
|
|
456
|
+
"OUT_OF_MEMORY",
|
|
457
|
+
(
|
|
458
|
+
"out of memory",
|
|
459
|
+
"cuda_error_out_of_memory",
|
|
460
|
+
"bad_alloc",
|
|
461
|
+
"failed to allocate",
|
|
462
|
+
"killed (137)",
|
|
463
|
+
"exit code 137",
|
|
464
|
+
"oom",
|
|
465
|
+
),
|
|
466
|
+
),
|
|
467
|
+
("HEALTH_TIMEOUT", ("timed out", "timeout", "not ready in")),
|
|
468
|
+
("PORT_IN_USE", ("address already in use", "eaddrinuse", "port is in use", "port in use")),
|
|
469
|
+
(
|
|
470
|
+
"PERMISSION_DENIED",
|
|
471
|
+
(
|
|
472
|
+
"permission denied",
|
|
473
|
+
"access is denied",
|
|
474
|
+
"eacces",
|
|
475
|
+
"winerror 5",
|
|
476
|
+
"winerror 32",
|
|
477
|
+
"private owned",
|
|
478
|
+
),
|
|
479
|
+
),
|
|
480
|
+
(
|
|
481
|
+
"DOWNLOAD_FAILED",
|
|
482
|
+
(
|
|
483
|
+
"download",
|
|
484
|
+
"urlerror",
|
|
485
|
+
"http error",
|
|
486
|
+
"ssl",
|
|
487
|
+
"connection refused",
|
|
488
|
+
"connection reset",
|
|
489
|
+
"name or service not known",
|
|
490
|
+
"getaddrinfo",
|
|
491
|
+
),
|
|
492
|
+
),
|
|
493
|
+
(
|
|
494
|
+
"ENGINE_START_FAILED",
|
|
495
|
+
(
|
|
496
|
+
"service exited",
|
|
497
|
+
"process exited",
|
|
498
|
+
"exited before becoming ready",
|
|
499
|
+
"launchd start failed",
|
|
500
|
+
"systemctl",
|
|
501
|
+
"no executable",
|
|
502
|
+
),
|
|
503
|
+
),
|
|
504
|
+
)
|
|
505
|
+
_STEP_REASONS: dict[str, str] = {
|
|
506
|
+
"download": "DOWNLOAD_FAILED",
|
|
507
|
+
"engine": "ENGINE_START_FAILED",
|
|
508
|
+
"install": "ENGINE_START_FAILED",
|
|
509
|
+
"start": "ENGINE_START_FAILED",
|
|
510
|
+
"verify": "ACCEPTANCE_FAILED",
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
def component_reason_code(part: Component) -> str | None:
|
|
515
|
+
"""Classify one failed component record into a fixed public reason code from
|
|
516
|
+
``COMPONENT_REASON_CODES`` without leaking raw stderr, paths, or error text."""
|
|
517
|
+
if part.get("status") != "failed":
|
|
518
|
+
return None
|
|
519
|
+
detail = str(part.get("detail") or "").lower()
|
|
520
|
+
if ("sha256" in detail or "digest" in detail) and (
|
|
521
|
+
"mismatch" in detail or "does not match" in detail
|
|
522
|
+
):
|
|
523
|
+
return "CHECKSUM_MISMATCH"
|
|
524
|
+
if "port" in detail and "in use" in detail:
|
|
525
|
+
return "PORT_IN_USE"
|
|
526
|
+
for code, tokens in _REASON_PATTERNS:
|
|
527
|
+
if any(token in detail for token in tokens):
|
|
528
|
+
return code
|
|
529
|
+
if (step_code := _STEP_REASONS.get(str(part.get("step") or "").lower())) is not None:
|
|
530
|
+
return step_code
|
|
531
|
+
checks = part.get("checks") or []
|
|
532
|
+
if (
|
|
533
|
+
part.get("component") == "acceptance"
|
|
534
|
+
or "readiness check failed" in detail
|
|
535
|
+
or any(isinstance(c, dict) and c.get("ok") is False for c in checks)
|
|
536
|
+
):
|
|
537
|
+
return "ACCEPTANCE_FAILED"
|
|
538
|
+
return None
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
def component_reasons(record: StackRecord) -> dict[str, str]:
|
|
542
|
+
"""Safe, fixed reason codes keyed by failed component name (in run order)."""
|
|
543
|
+
if record["ok"]:
|
|
544
|
+
return {}
|
|
545
|
+
found: dict[str, str] = {}
|
|
546
|
+
for part in record["components"]:
|
|
547
|
+
name = part.get("component")
|
|
548
|
+
if not isinstance(name, str) or name not in COMPONENTS:
|
|
549
|
+
continue
|
|
550
|
+
code = component_reason_code(part)
|
|
551
|
+
if code is not None and code in COMPONENT_REASON_CODES:
|
|
552
|
+
found[name] = code
|
|
553
|
+
return found
|
|
554
|
+
|
|
555
|
+
|
|
448
556
|
def component_failure(record: StackRecord) -> tuple[list[str], tuple[str, str]] | None:
|
|
449
557
|
"""For a run that ended not ok: the components that did not pass, in run order (a planned
|
|
450
558
|
one that never ran counts), and the public cause. Names come from the fixed component set,
|
|
@@ -488,6 +596,7 @@ def machine_result(
|
|
|
488
596
|
state, code = "failed", "1"
|
|
489
597
|
exit_code = int(code)
|
|
490
598
|
failure = component_failure(record) if record is not None and state == "failed" else None
|
|
599
|
+
reasons = component_reasons(record) if record is not None and failure is not None else {}
|
|
491
600
|
if failure is not None and cause is None:
|
|
492
601
|
cause = failure[1]
|
|
493
602
|
print(
|
|
@@ -510,6 +619,14 @@ def machine_result(
|
|
|
510
619
|
else {}
|
|
511
620
|
),
|
|
512
621
|
**({"failed_components": failure[0]} if failure is not None else {}),
|
|
622
|
+
**(
|
|
623
|
+
{
|
|
624
|
+
"component_reasons": reasons,
|
|
625
|
+
"reason_code": next(iter(reasons.values())),
|
|
626
|
+
}
|
|
627
|
+
if reasons
|
|
628
|
+
else {}
|
|
629
|
+
),
|
|
513
630
|
**({"cause_code": cause[0], "message": cause[1]} if cause else {}),
|
|
514
631
|
},
|
|
515
632
|
separators=(",", ":"),
|
|
@@ -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
|
-
|
|
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,7 +48,9 @@ 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",
|
|
53
|
+
"remote_ops_ranges.py",
|
|
52
54
|
"remote_ops_service.py",
|
|
53
55
|
"remote_ops_verify.py",
|
|
54
56
|
"remote_ops_remove.py",
|