@simplexai/localmodels-linux-arm64 0.1.0-dev.58 → 0.1.0-dev.59
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 +57 -56
- package/modules/localmodels/__init__.py +1 -1
- package/modules/localmodels/app.py +1 -1
- package/modules/localmodels/bifrost_admin.py +53 -8
- package/modules/localmodels/bifrost_config.py +103 -4
- package/modules/localmodels/bifrost_log.py +166 -0
- package/modules/localmodels/budget.py +1 -1
- package/modules/localmodels/catalog.json +55 -32
- package/modules/localmodels/engines-strata-poly-0.2.20-poly.5.json +94 -0
- package/modules/localmodels/frontend.py +26 -21
- package/modules/localmodels/gateway_bifrost.py +30 -6
- package/modules/localmodels/hosts.py +99 -12
- package/modules/localmodels/library_convert.py +34 -0
- package/modules/localmodels/library_elastic.py +150 -123
- package/modules/localmodels/library_gateway.py +101 -10
- package/modules/localmodels/library_jobs.py +16 -7
- package/modules/localmodels/library_pricing.py +14 -4
- package/modules/localmodels/library_serve.py +84 -16
- package/modules/localmodels/library_state.py +4 -1
- package/modules/localmodels/library_status.py +18 -4
- package/modules/localmodels/metal.py +1 -1
- package/modules/localmodels/metal_probe.py +4 -4
- package/modules/localmodels/plan_envelope.py +4 -1
- package/modules/localmodels/process_identity_linux.py +39 -0
- package/modules/localmodels/remote_ops.py +4 -3
- package/modules/localmodels/remote_ops_download.py +37 -24
- package/modules/localmodels/remote_ops_mirrors.py +43 -2
- package/modules/localmodels/remote_ops_service.py +93 -36
- package/modules/localmodels/runtime_auth.py +4 -1
- package/modules/localmodels/service_wiring.py +238 -12
- package/modules/localmodels/setup_inspection.py +47 -70
- package/modules/localmodels/setup_inspection_harness.py +159 -15
- package/modules/localmodels/setup_text.py +14 -0
- package/modules/localmodels/setup_upgrade.py +1 -1
- package/modules/localmodels/source_byok.py +6 -2
- package/modules/localmodels/source_byok_probe.py +6 -1
- package/modules/localmodels/stack.py +9 -1
- package/modules/localmodels/stack_binding.py +3 -35
- package/modules/localmodels/stack_cleanup.py +4 -0
- package/modules/localmodels/stack_compose.py +18 -2
- package/modules/localmodels/stack_lifecycle.py +24 -1
- package/modules/localmodels/stack_plan.py +6 -2
- package/modules/localmodels/stack_ports.py +2 -0
- package/modules/localmodels/stack_remove.py +10 -1
- package/modules/localmodels/stack_up.py +33 -7
- package/modules/localmodels/stack_update.py +3 -1
- package/modules/localmodels/{strata-poly-serve-0.2.19-poly.1.txt → strata-poly-serve-0.2.20-poly.5.txt} +1 -1
- package/modules/localmodels/suite.py +43 -27
- package/modules/localmodels/transport.py +13 -2
- package/modules/{simplex_localmodels-0.1.0.dev58.dist-info → simplex_localmodels-0.1.0.dev59.dist-info}/METADATA +1 -1
- package/modules/{simplex_localmodels-0.1.0.dev58.dist-info → simplex_localmodels-0.1.0.dev59.dist-info}/RECORD +54 -53
- package/package.json +1 -1
- package/tool.json +1 -1
- package/modules/localmodels/engines-strata-poly-0.2.19-poly.1.json +0 -79
- /package/modules/{simplex_localmodels-0.1.0.dev58.dist-info → simplex_localmodels-0.1.0.dev59.dist-info}/WHEEL +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev58.dist-info → simplex_localmodels-0.1.0.dev59.dist-info}/entry_points.txt +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev58.dist-info → simplex_localmodels-0.1.0.dev59.dist-info}/licenses/NOTICE +0 -0
- /package/modules/{simplex_localmodels-0.1.0.dev58.dist-info → simplex_localmodels-0.1.0.dev59.dist-info}/licenses/localmodels/HERMES-LICENSE +0 -0
|
@@ -19,6 +19,7 @@ from typing import Any
|
|
|
19
19
|
|
|
20
20
|
from localmodels import (
|
|
21
21
|
bifrost_datasheet,
|
|
22
|
+
bifrost_log,
|
|
22
23
|
bifrost_unit,
|
|
23
24
|
gateway_home,
|
|
24
25
|
gateway_keys,
|
|
@@ -42,6 +43,7 @@ from localmodels.bifrost_config import differs as _config_differs
|
|
|
42
43
|
from localmodels.bifrost_config import read_config as read_config
|
|
43
44
|
from localmodels.bifrost_config import render as render
|
|
44
45
|
from localmodels.bifrost_config import render_config as render_config
|
|
46
|
+
from localmodels.bifrost_config import sanitize_governance as sanitize_governance
|
|
45
47
|
from localmodels.bifrost_config import write_config as write_config
|
|
46
48
|
from localmodels.bifrost_provider import origin as origin
|
|
47
49
|
from localmodels.bifrost_unit import unit, unit_file, unit_for
|
|
@@ -333,9 +335,16 @@ def healthy(addr: str, timeout: float = 5) -> bool:
|
|
|
333
335
|
return False
|
|
334
336
|
|
|
335
337
|
|
|
336
|
-
def _await(
|
|
338
|
+
def _await(
|
|
339
|
+
addr: str,
|
|
340
|
+
timeout: float = HEALTH_TIMEOUT_S,
|
|
341
|
+
*,
|
|
342
|
+
record: hosts.OwnedBifrost,
|
|
343
|
+
log_offset: int = 0,
|
|
344
|
+
) -> None:
|
|
337
345
|
deadline = time.monotonic() + timeout
|
|
338
|
-
|
|
346
|
+
app = Path(record["app_dir"])
|
|
347
|
+
pid_file = app / "bifrost.pid"
|
|
339
348
|
while time.monotonic() < deadline:
|
|
340
349
|
if _healthy_owned(record):
|
|
341
350
|
return
|
|
@@ -344,6 +353,12 @@ def _await(addr: str, timeout: float = HEALTH_TIMEOUT_S, *, record: hosts.OwnedB
|
|
|
344
353
|
and os.path.lexists(pid_file)
|
|
345
354
|
and process_identity.status(pid_file)[0] == "inactive"
|
|
346
355
|
):
|
|
356
|
+
summary = bifrost_log.startup_failure_summary(app, log_offset, app_label=APP_DIR)
|
|
357
|
+
if summary:
|
|
358
|
+
raise HarnessError(
|
|
359
|
+
f"Bifrost {addr} exited before becoming ready ({summary}); "
|
|
360
|
+
f"see {APP_DIR}/bifrost.log"
|
|
361
|
+
)
|
|
347
362
|
raise HarnessError(
|
|
348
363
|
f"Bifrost {addr} exited before becoming ready; see {APP_DIR}/bifrost.log"
|
|
349
364
|
)
|
|
@@ -546,9 +561,17 @@ def revive(plan: HarnessPlan) -> str:
|
|
|
546
561
|
return "reused"
|
|
547
562
|
if not record:
|
|
548
563
|
raise HarnessError("the ownership manifest has no record of this tool's Bifrost gateway")
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
564
|
+
app = Path(record["app_dir"])
|
|
565
|
+
config = read_config(app)
|
|
566
|
+
sanitized = bool(config and sanitize_governance(config))
|
|
567
|
+
if sanitized:
|
|
568
|
+
if STOP_BEFORE_CONFIG_CHANGE and record["how"] != "unit":
|
|
569
|
+
_stop_owned_serve(record)
|
|
570
|
+
_write_config(app, config)
|
|
571
|
+
log_offset = bifrost_log.log_size(app)
|
|
572
|
+
_start(record, restart=sanitized)
|
|
573
|
+
_await(addr, record=record, log_offset=log_offset)
|
|
574
|
+
_seal(app)
|
|
552
575
|
return "started"
|
|
553
576
|
|
|
554
577
|
|
|
@@ -604,8 +627,9 @@ def wire(
|
|
|
604
627
|
_stop_owned_serve(record)
|
|
605
628
|
changed = _write_config(app, config, sheets)
|
|
606
629
|
if changed or not _healthy_owned(record):
|
|
630
|
+
log_offset = bifrost_log.log_size(app)
|
|
607
631
|
_start(record, restart=changed)
|
|
608
|
-
_await(record["addr"], record=record)
|
|
632
|
+
_await(record["addr"], record=record, log_offset=log_offset)
|
|
609
633
|
_seal(app)
|
|
610
634
|
done = [f"provider {pid}" for pid in config["providers"]]
|
|
611
635
|
default = gw.get("llm_fast") or gw["llm"]
|
|
@@ -249,14 +249,33 @@ def load_facts(dev_id: str) -> HostFacts | None:
|
|
|
249
249
|
return _read(state_dir() / "facts" / f"{dev_id}.json", None, lambda v: decode(v, HostFacts))
|
|
250
250
|
|
|
251
251
|
|
|
252
|
+
def _same_place(a: str, b: str) -> bool:
|
|
253
|
+
def norm(path: str) -> str:
|
|
254
|
+
return os.path.normcase(os.path.realpath(os.path.expanduser(path)))
|
|
255
|
+
|
|
256
|
+
return norm(a) == norm(b)
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
def _record_touched_service(record: FinishedRecord) -> bool:
|
|
260
|
+
"""True when a deployment succeeded or got far enough that it may have installed or started
|
|
261
|
+
service files on this computer. A deploy that failed before ``install`` succeeded (for
|
|
262
|
+
example, refused on a port or unit conflict) created no owned service."""
|
|
263
|
+
if record["ok"]:
|
|
264
|
+
return True
|
|
265
|
+
steps = record.get("steps") or []
|
|
266
|
+
if not steps:
|
|
267
|
+
return True
|
|
268
|
+
return any(step["step"] in ("install", "start", "verify") and step["ok"] for step in steps)
|
|
269
|
+
|
|
270
|
+
|
|
252
271
|
def save_record(dev_id: str, record: FinishedRecord) -> Path:
|
|
253
|
-
"""Keep the record; a deployment on this computer also enters the owned manifest
|
|
254
|
-
|
|
272
|
+
"""Keep the record; a deployment on this computer also enters the owned manifest when it
|
|
273
|
+
succeeded or installed service files, without overwriting another live deployment."""
|
|
255
274
|
plan = record["plan"]
|
|
256
275
|
path = state_dir() / "deployments" / dev_id / f"{plan['name']}.json"
|
|
257
276
|
_write(path, record)
|
|
258
|
-
if dev_id == LOCAL_ID:
|
|
259
|
-
own_deployment(plan)
|
|
277
|
+
if dev_id == LOCAL_ID and _record_touched_service(record):
|
|
278
|
+
own_deployment(plan, ok=record["ok"])
|
|
260
279
|
return path
|
|
261
280
|
|
|
262
281
|
|
|
@@ -272,8 +291,20 @@ def records(dev_id: str) -> list[FinishedRecord]:
|
|
|
272
291
|
|
|
273
292
|
|
|
274
293
|
def deployment_dirs(dev_id: str) -> dict[str, str]:
|
|
275
|
-
"""Each recorded deployment's name and directory: which names are already in use, and where.
|
|
276
|
-
|
|
294
|
+
"""Each recorded deployment's name and directory: which names are already in use, and where.
|
|
295
|
+
On this computer the shared owned manifest is included too so independent controllers with
|
|
296
|
+
separate state directories do not collide on one deployment name."""
|
|
297
|
+
taken = {r["plan"]["name"]: r["plan"]["service"]["deploy_dir"] for r in records(dev_id)}
|
|
298
|
+
if dev_id == LOCAL_ID and owned_path().is_file():
|
|
299
|
+
try:
|
|
300
|
+
for name, entry in load_owned()["deployments"].items():
|
|
301
|
+
if entry["removed"] or entry.get("failed"):
|
|
302
|
+
continue
|
|
303
|
+
if name not in taken or not _same_place(taken[name], entry["deploy_dir"]):
|
|
304
|
+
taken[name] = entry["deploy_dir"]
|
|
305
|
+
except (OSError, ValueError):
|
|
306
|
+
pass
|
|
307
|
+
return taken
|
|
277
308
|
|
|
278
309
|
|
|
279
310
|
def record(dev_id: str, name: str) -> FinishedRecord:
|
|
@@ -287,22 +318,33 @@ def record(dev_id: str, name: str) -> FinishedRecord:
|
|
|
287
318
|
return hit
|
|
288
319
|
|
|
289
320
|
|
|
290
|
-
def delete_record(
|
|
321
|
+
def delete_record(
|
|
322
|
+
dev_id: str, name: str, *, purged: bool = False, deploy_dir: str | None = None
|
|
323
|
+
) -> None:
|
|
291
324
|
"""Forget a removed deployment. On this computer the owned manifest keeps it as removed, its
|
|
292
|
-
files and log left for a purge, or drops it when ``purged
|
|
325
|
+
files and log left for a purge, or drops it when ``purged`` — only when the manifest entry
|
|
326
|
+
belongs to this deployment's directory, never another controller's."""
|
|
293
327
|
path = state_dir() / "deployments" / dev_id / f"{name}.json"
|
|
328
|
+
recorded_dir = deploy_dir
|
|
329
|
+
if recorded_dir is None and path.is_file():
|
|
330
|
+
existing = _read(path, None, lambda v: decode(v, FinishedRecord))
|
|
331
|
+
if existing is not None:
|
|
332
|
+
recorded_dir = existing["plan"]["service"]["deploy_dir"]
|
|
294
333
|
if path.exists():
|
|
295
334
|
path.unlink()
|
|
296
335
|
if dev_id != LOCAL_ID:
|
|
297
336
|
return
|
|
298
337
|
|
|
299
338
|
def change(doc: Owned) -> None:
|
|
300
|
-
|
|
339
|
+
entry = doc["deployments"].get(name)
|
|
340
|
+
if entry is None:
|
|
341
|
+
return
|
|
342
|
+
if recorded_dir is not None and not _same_place(entry["deploy_dir"], recorded_dir):
|
|
301
343
|
return
|
|
302
344
|
if purged:
|
|
303
345
|
del doc["deployments"][name]
|
|
304
346
|
else:
|
|
305
|
-
|
|
347
|
+
entry["removed"] = True
|
|
306
348
|
|
|
307
349
|
if owned_path().is_file():
|
|
308
350
|
update_owned(change)
|
|
@@ -316,6 +358,9 @@ OWNED_SCHEMA = "localmodels.owned/v1"
|
|
|
316
358
|
|
|
317
359
|
class _OwnedPreparation(TypedDict, total=False):
|
|
318
360
|
preparation_dir: str
|
|
361
|
+
failed: (
|
|
362
|
+
bool # True when recorded from a failed/interrupted deploy; never blocks a verified owner
|
|
363
|
+
)
|
|
319
364
|
|
|
320
365
|
|
|
321
366
|
class OwnedDeployment(_OwnedPreparation):
|
|
@@ -609,13 +654,55 @@ def owned_entry(plan: Plan) -> OwnedDeployment:
|
|
|
609
654
|
return entry
|
|
610
655
|
|
|
611
656
|
|
|
612
|
-
def
|
|
613
|
-
"""
|
|
657
|
+
def port_owned_elsewhere(port: int, deploy_dir: str, tools_dir: str | Path = TOOLS_DIR) -> bool:
|
|
658
|
+
"""True when the shared owned manifest records another live verified deployment on ``port``."""
|
|
659
|
+
if not owned_path(tools_dir).is_file():
|
|
660
|
+
return False
|
|
661
|
+
try:
|
|
662
|
+
entries = load_owned(tools_dir)["deployments"].values()
|
|
663
|
+
except (OSError, ValueError):
|
|
664
|
+
return False
|
|
665
|
+
return any(
|
|
666
|
+
not entry["removed"]
|
|
667
|
+
and not entry.get("failed")
|
|
668
|
+
and entry["port"] == port
|
|
669
|
+
and not _same_place(entry["deploy_dir"], deploy_dir)
|
|
670
|
+
for entry in entries
|
|
671
|
+
)
|
|
672
|
+
|
|
673
|
+
|
|
674
|
+
def own_deployment(plan: Plan, tools_dir: str | Path = TOOLS_DIR, *, ok: bool = True) -> bool:
|
|
675
|
+
"""Record a deployment on this computer (``owned_entry``). Never overwrites a live verified
|
|
676
|
+
manifest entry belonging to another directory, never claims a unit owned by another live
|
|
677
|
+
verified deployment, and on failure never registers a competing owner on a port another live
|
|
678
|
+
deployment holds."""
|
|
614
679
|
entry = owned_entry(plan)
|
|
680
|
+
if not ok:
|
|
681
|
+
entry["failed"] = True
|
|
682
|
+
recorded = False
|
|
615
683
|
|
|
616
684
|
def add(doc: Owned) -> None:
|
|
685
|
+
nonlocal recorded
|
|
686
|
+
existing = doc["deployments"].get(plan["name"])
|
|
687
|
+
if existing is not None and not _same_place(existing["deploy_dir"], entry["deploy_dir"]):
|
|
688
|
+
existing_live = not existing["removed"] and not existing.get("failed")
|
|
689
|
+
if existing_live or not ok:
|
|
690
|
+
return
|
|
691
|
+
for other in doc["deployments"].values():
|
|
692
|
+
if (
|
|
693
|
+
other["removed"]
|
|
694
|
+
or other.get("failed")
|
|
695
|
+
or _same_place(other["deploy_dir"], entry["deploy_dir"])
|
|
696
|
+
):
|
|
697
|
+
continue
|
|
698
|
+
if other["service"] == entry["service"]:
|
|
699
|
+
return
|
|
700
|
+
if not ok and other["port"] == entry["port"]:
|
|
701
|
+
return
|
|
617
702
|
doc["deployments"][plan["name"]] = entry
|
|
618
703
|
if entry["slice"]:
|
|
619
704
|
doc["slices"] = sorted({*doc["slices"], entry["slice"]})
|
|
705
|
+
recorded = True
|
|
620
706
|
|
|
621
707
|
update_owned(add, tools_dir)
|
|
708
|
+
return recorded
|
|
@@ -142,6 +142,38 @@ def _planned_stack_llms(plan: StackPlan | None) -> dict[str, str]:
|
|
|
142
142
|
return found
|
|
143
143
|
|
|
144
144
|
|
|
145
|
+
def adopted_components(plan: StackPlan) -> set[str]:
|
|
146
|
+
"""The plan's LLM components the library adopted: from then on the
|
|
147
|
+
library loads, unloads, wires and may remove them, so their deployments, gateway route and
|
|
148
|
+
pi selection are no longer the stack's to check. The conversion marker names them, and
|
|
149
|
+
stays when ``library remove`` deletes the model's record; a converted record (an earlier
|
|
150
|
+
one may lack ``stack_provider``: the main LLM's) names them too. Read only; it never
|
|
151
|
+
converts."""
|
|
152
|
+
from localmodels import stack_verify
|
|
153
|
+
|
|
154
|
+
try:
|
|
155
|
+
marker = json.loads((library_state.root() / MARKER).read_text("utf-8"))
|
|
156
|
+
except (OSError, ValueError):
|
|
157
|
+
return set()
|
|
158
|
+
if not isinstance(marker, dict) or marker.get("plan_id") != plan["plan_id"]:
|
|
159
|
+
return set()
|
|
160
|
+
ids = set(marker.get("adopted") or [])
|
|
161
|
+
providers = {
|
|
162
|
+
r.get("stack_provider") or harness.LLM_PROVIDER
|
|
163
|
+
for r in library_state.records()
|
|
164
|
+
if r.get("converted")
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
component
|
|
168
|
+
for component, part in stack_verify.parts(plan)
|
|
169
|
+
if component in STACK_LLMS
|
|
170
|
+
and (
|
|
171
|
+
library_id(part["model"]["id"], part["model"]["quant"]) in ids
|
|
172
|
+
or STACK_LLMS[component] in providers
|
|
173
|
+
)
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
|
|
145
177
|
def _active_stack_llms(plan: StackPlan | None) -> dict[str, tuple[str, Plan]]:
|
|
146
178
|
"""Accepted stack LLM deployments still present and ok on disk: ``library_id -> (provider, plan)``."""
|
|
147
179
|
if plan is None:
|
|
@@ -299,6 +331,8 @@ def _adopt_record(model: str, provider: str, deployed: Plan, base_dir: str | Non
|
|
|
299
331
|
record["quant"] = spec["quant"]
|
|
300
332
|
record["pool"] = pool
|
|
301
333
|
record["plan"] = deployed
|
|
334
|
+
record.pop("baseline_plan", None)
|
|
335
|
+
record.pop("load_posture", None)
|
|
302
336
|
record["pi_model"] = gateway_bifrost.PI_MODEL
|
|
303
337
|
record["state"] = "loaded"
|
|
304
338
|
record["converted"] = True
|