The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(platform): machine.facts names the NVIDIA platform from nvidia_platform()
alt-glitch9fb5e24c9f2b
diff --git a/apps/shared/src/gateway-contract.generated.ts b/apps/shared/src/gateway-contract.generated.tsindex a46b746d3d9..fcd856a2446 100644--- a/apps/shared/src/gateway-contract.generated.ts+++ b/apps/shared/src/gateway-contract.generated.ts@@ -1919,12 +1919,12 @@ export interface ClientCapabilitiesResult {}/** Client→server method params / server→client request params. Unknown keys are rejected. */export type Params = Record<string, never>-/** ``machine_kind`` is ``Spark``, ``Mac``, ``PC`` or ``computer``. ``full_name`` is the OS account's real name (never a login handle) and ``locale`` its first UI language; each is null when the OS has none. */+/** ``machine_kind`` is ``Spark``, ``Mac``, ``PC`` or ``computer``. ``nvidia_platform`` is ``products.nvidia_platform()``: ``rtx_spark``, ``dgx_spark``, ``discrete`` or null. ``full_name`` is the OS account's real name (never a login handle) and ``locale`` its first UI language; each is null when the OS has none. */export interface MachineFactsResult {machine: MachineInfomachine_kind: stringhas_nvidia_gpu: boolean- is_spark: boolean+ nvidia_platform?: 'rtx_spark' | 'dgx_spark' | 'discrete' | nulllocale?: string | nullfull_name?: string | null}diff --git a/apps/shared/src/gateway-contract.openrpc.json b/apps/shared/src/gateway-contract.openrpc.jsonindex 43e60574c3a..a584973b45e 100644--- a/apps/shared/src/gateway-contract.openrpc.json+++ b/apps/shared/src/gateway-contract.openrpc.json@@ -17976,7 +17976,7 @@},"MachineFactsResult": {"additionalProperties": false,- "description": "``machine_kind`` is ``Spark``, ``Mac``, ``PC`` or ``computer``. ``full_name`` is the OS account's\nreal name (never a login handle) and ``locale`` its first UI language; each is null when the OS has none.",+ "description": "``machine_kind`` is ``Spark``, ``Mac``, ``PC`` or ``computer``. ``nvidia_platform`` is\n``products.nvidia_platform()``: ``rtx_spark``, ``dgx_spark``, ``discrete`` or null. ``full_name`` is the OS account's\nreal name (never a login handle) and ``locale`` its first UI language; each is null when the OS has none.","properties": {"machine": {"$ref": "#/components/schemas/MachineInfo"@@ -17989,9 +17989,22 @@"title": "Has Nvidia Gpu","type": "boolean"},- "is_spark": {- "title": "Is Spark",- "type": "boolean"+ "nvidia_platform": {+ "anyOf": [+ {+ "enum": [+ "rtx_spark",+ "dgx_spark",+ "discrete"+ ],+ "type": "string"+ },+ {+ "type": "null"+ }+ ],+ "default": null,+ "title": "Nvidia Platform"},"locale": {"anyOf": [@@ -18021,8 +18034,7 @@"required": ["machine","machine_kind",- "has_nvidia_gpu",- "is_spark"+ "has_nvidia_gpu"],"title": "MachineFactsResult","type": "object"diff --git a/hermes_platform/host/summary.py b/hermes_platform/host/summary.pyindex fd6781533ef..2eb1823bc0e 100644--- a/hermes_platform/host/summary.py+++ b/hermes_platform/host/summary.py@@ -22,7 +22,6 @@ _NON_NAMES = frozenset({"admin", "administrator", "default", "guest", "me", "owner", "root", "test", "user",})_HANDLE_CHARS = re.compile(r"[\d_@/\\]")-_SPARK_MODEL = re.compile(r"\b(dgx|spark|gb10)\b", re.IGNORECASE)# --- account facts -----------------------------------------------------------------@@ -135,14 +134,8 @@ def _locale() -> str:# --- the summary -----------------------------------------------------------------------def is_spark(os_family: str, arch: str, gpu: str, cpu: str) -> bool:- """RTX Sparks by platform, architecture and GPU; DGX Sparks by model string."""- rtx = os_family == "win32" and arch == "arm64" and gpu == "nvidia"- return rtx or products.is_nvidia_arm_soc() or bool(_SPARK_MODEL.search(cpu.replace("_", " ")))---def _machine_kind(os_family: str, spark: bool) -> str:- if spark:+def _machine_kind(os_family: str, nvidia: str | None) -> str:+ if nvidia in ("rtx_spark", "dgx_spark"):return "Spark"return {"darwin": "Mac", "win32": "PC"}.get(os_family, "computer")@@ -158,7 +151,7 @@ def summary() -> dict:``locale`` and ``full_name`` are None when the OS has none to give."""os_family, arch, gpu, cpu = host.os_family(), host.native_arch(), host.gpu_class(), host.cpu_model()ram = host.ram_total_bytes()- spark = is_spark(os_family, arch, gpu, cpu)+ nvidia = products.nvidia_platform()machine = {"os_family": os_family,"os_release": _os_release(os_family),@@ -172,9 +165,9 @@ def summary() -> dict:}return {"machine": {key: value for key, value in machine.items() if value not in (None, "")},- "machine_kind": _machine_kind(os_family, spark),+ "machine_kind": _machine_kind(os_family, nvidia),"has_nvidia_gpu": gpu == "nvidia",- "is_spark": spark,+ "nvidia_platform": nvidia,"locale": _locale() or None,"full_name": full_name_from(*_account()),}diff --git a/tests/hermes_platform/test_host_summary.py b/tests/hermes_platform/test_host_summary.pyindex a723a5b5c55..c9be72c6428 100644--- a/tests/hermes_platform/test_host_summary.py+++ b/tests/hermes_platform/test_host_summary.py@@ -1,4 +1,4 @@-"""``hermes_platform.host.summary``: the machine and account facts the desktop questionnaire reads."""+"""``hermes_platform.host.summary``: the machine and account facts desktop first-run onboarding reads."""from __future__ import annotations@@ -14,7 +14,7 @@ _N1X = "NVIDIA RTX Spark N1X"def machine(monkeypatch):"""Pin every hardware fact; returns a setter for the ones a case changes."""values = {"os_family": "linux", "native_arch": "amd64", "gpu_class": "unknown", "cpu_model": "",- "cpu_vendor": "", "ram_total_bytes": 16 * 2**30}+ "cpu_vendor": "", "ram_total_bytes": 16 * 2**30, "nvidia_gpus": ()}def pin(**changes):values.update(changes)@@ -31,7 +31,7 @@ def machine(monkeypatch):def test_shape(machine):result = machine()- assert set(result) == {"machine", "machine_kind", "has_nvidia_gpu", "is_spark", "locale", "full_name"}+ assert set(result) == {"machine", "machine_kind", "has_nvidia_gpu", "nvidia_platform", "locale", "full_name"}assert result["machine"]["os_family"] == "linux"assert result["machine"]["ram_gb"] == 16assert "gpu_class" not in result["machine"] # unmeasured keys are left out, not sent as null@@ -39,17 +39,13 @@ def test_shape(machine):assert result["locale"] is None or isinstance(result["locale"], str)-def test_n1x_cpu_string_is_a_spark(machine):+def test_n1x_cpu_string_is_an_rtx_spark(machine):result = machine(os_family="win32", native_arch="arm64", cpu_model=_N1X, cpu_vendor="NVIDIA")- assert result["is_spark"] is True+ assert result["nvidia_platform"] == "rtx_spark"assert result["machine_kind"] == "Spark"-def test_dgx_spark_by_model_string(machine):- assert machine(native_arch="arm64", cpu_model="DGX_Spark GB10")["is_spark"] is True--@pytest.mark.parametrize(("os_family", "arch", "gpu", "kind", "nvidia"), [("win32", "amd64", "nvidia", "PC", True),("darwin", "arm64", "unknown", "Mac", False),@@ -58,7 +54,7 @@ def test_dgx_spark_by_model_string(machine):def test_ordinary_machines_are_not_sparks(machine, os_family, arch, gpu, kind, nvidia):result = machine(os_family=os_family, native_arch=arch, gpu_class=gpu, cpu_model="Generic CPU")- assert result["is_spark"] is False+ assert result["nvidia_platform"] == ("discrete" if nvidia else None)assert result["machine_kind"] == kindassert result["has_nvidia_gpu"] is nvidiadiff --git a/tests/tui_gateway/test_machine_facts_rpc.py b/tests/tui_gateway/test_machine_facts_rpc.pyindex 7920a63a575..49f021d9b40 100644--- a/tests/tui_gateway/test_machine_facts_rpc.py+++ b/tests/tui_gateway/test_machine_facts_rpc.py@@ -12,7 +12,8 @@ from hermes_platform.host import facts, summary@pytest.fixturedef n1x(monkeypatch):pinned = {"os_family": "win32", "native_arch": "arm64", "gpu_class": "unknown",- "cpu_model": "NVIDIA RTX Spark N1X", "cpu_vendor": "NVIDIA", "ram_total_bytes": 128 * 2**30}+ "cpu_model": "NVIDIA RTX Spark N1X", "cpu_vendor": "NVIDIA", "ram_total_bytes": 128 * 2**30,+ "nvidia_gpus": ()}for name, value in pinned.items():monkeypatch.setattr(facts, name, lambda value=value: value)monkeypatch.setattr(summary, "_account", lambda: ("ada", "Ada Lovelace"))@@ -28,7 +29,7 @@ def _call(params: dict) -> dict:def test_machine_facts_over_the_wire(n1x):result = _call({})["result"]- assert result["is_spark"] is True+ assert result["nvidia_platform"] == "rtx_spark"assert result["machine_kind"] == "Spark"assert result["has_nvidia_gpu"] is Falseassert result["full_name"] == "Ada Lovelace"diff --git a/tui_gateway/contracts/machine.py b/tui_gateway/contracts/machine.pyindex 39e86db4aa9..5643d021ee1 100644--- a/tui_gateway/contracts/machine.py+++ b/tui_gateway/contracts/machine.py@@ -6,6 +6,8 @@ profile one backend serves.from __future__ import annotations+from hermes_platform.host.products import NvidiaPlatform+from .base import Params, Resultfrom .registry import method@@ -25,13 +27,14 @@ class MachineInfo(Result):class MachineFactsResult(Result):- """``machine_kind`` is ``Spark``, ``Mac``, ``PC`` or ``computer``. ``full_name`` is the OS account's+ """``machine_kind`` is ``Spark``, ``Mac``, ``PC`` or ``computer``. ``nvidia_platform`` is+ ``products.nvidia_platform()``: ``rtx_spark``, ``dgx_spark``, ``discrete`` or null. ``full_name`` is the OS account'sreal name (never a login handle) and ``locale`` its first UI language; each is null when the OS has none."""machine: MachineInfomachine_kind: strhas_nvidia_gpu: bool- is_spark: bool+ nvidia_platform: NvidiaPlatform | None = Nonelocale: str | None = Nonefull_name: str | None = None