aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorChristophe Besson <cbesson@gmail.com>2026-10-11 21:17:09 +0200
committerChristophe Besson <cbesson@gmail.com>2026-10-11 21:17:09 +0200
commit1667fdcb1a621296eefc5ed90d846c1f77715c76 (patch)
tree3626f1dd5a6281473dea4f59382d107251ca4d40 /packages
parent2ef0c215ea4af421a4b22ab543a5999320998f68 (diff)
downloadmeshbay-1667fdcb1a621296eefc5ed90d846c1f77715c76.tar.gz
fix(node): tell the Node page how many cores there are
The page reads its settings from list_groups, which lacked cpu_count, so the field showed "of 1" and stayed at 1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'packages')
-rw-r--r--packages/meshbay-node/src/meshbay_node/ops/groups.py11
-rw-r--r--packages/meshbay-node/src/meshbay_node/ops/settings.py22
-rw-r--r--packages/meshbay-node/tests/test_connection_processes.py11
3 files changed, 30 insertions, 14 deletions
diff --git a/packages/meshbay-node/src/meshbay_node/ops/groups.py b/packages/meshbay-node/src/meshbay_node/ops/groups.py
index ac14c3a..f6fdff2 100644
--- a/packages/meshbay-node/src/meshbay_node/ops/groups.py
+++ b/packages/meshbay-node/src/meshbay_node/ops/groups.py
@@ -130,15 +130,8 @@ async def list_groups(state: dict) -> dict:
members = await roster.list_members()
has_operator = any(m["role"] == "operator" and m["status"] == "active"
for m in members)
- from meshbay_node.config import node_settings_defaults
- # No config (a test, an unconfigured node) falls back to NodeConfig()'s own
- # values rather than to numbers repeated here, which is the copy this used
- # to be: it was missing three settings and reported them as null.
- defaults = node_settings_defaults(config.node if config else None)
- if roster:
- settings = await roster.node_settings(defaults)
- else:
- settings = defaults
+ from meshbay_node.ops.settings import node_settings_view
+ settings = await node_settings_view(roster, config)
return {"groups": out, "operator_paired": has_operator, "settings": settings}
diff --git a/packages/meshbay-node/src/meshbay_node/ops/settings.py b/packages/meshbay-node/src/meshbay_node/ops/settings.py
index 9be9aca..77e0b77 100644
--- a/packages/meshbay-node/src/meshbay_node/ops/settings.py
+++ b/packages/meshbay-node/src/meshbay_node/ops/settings.py
@@ -67,17 +67,29 @@ NODE_SETTING_WRITERS: dict[str, tuple[str, str]] = {
}
-async def get_node_settings(state: dict) -> dict:
- """Return current effective node settings."""
+async def node_settings_view(roster, config) -> dict:
+ """The effective settings, as every reader of them gets them.
+
+ One function because there were two: the Node page reads its settings from
+ `list_groups`, not from `get_node_settings`, and a key added to one alone
+ (`cpu_count`) left the page showing "of 1" on a machine with 28 cores, its
+ field held at 1.
+
+ No config (a test, an unconfigured node) falls back to NodeConfig()'s own
+ values rather than to numbers repeated here.
+ """
from meshbay_node.config import node_settings_defaults
- roster = _roster(state)
- config = _config(state)
- defaults = node_settings_defaults(config.node)
+ defaults = node_settings_defaults(config.node if config else None)
settings = await roster.node_settings(defaults) if roster else defaults
# Not a setting: the ceiling of `connection_processes` on this machine, so
# the Node page can say how far the operator may go. The writer ignores it.
return {**settings, "cpu_count": max_processes()}
+
+async def get_node_settings(state: dict) -> dict:
+ """Return current effective node settings."""
+ return await node_settings_view(_roster(state), _config(state))
+
async def set_node_settings(state: dict, settings: dict) -> dict:
"""Update node-level daemon settings. Writes to both roster.db and node.toml."""
roster = _roster(state)
diff --git a/packages/meshbay-node/tests/test_connection_processes.py b/packages/meshbay-node/tests/test_connection_processes.py
index 5eea9b9..47aded0 100644
--- a/packages/meshbay-node/tests/test_connection_processes.py
+++ b/packages/meshbay-node/tests/test_connection_processes.py
@@ -272,6 +272,17 @@ async def test_the_setting_is_applied_now_and_kept(state, monkeypatch):
@pytest.mark.asyncio
+async def test_the_node_page_is_told_how_many_cores_there_are(state, monkeypatch):
+ """The page takes its settings from `list_groups`. It was told the ceiling
+ only by `get_node_settings`, which it never calls, and showed "of 1"."""
+ monkeypatch.setattr("meshbay_node.ops.settings.max_processes", lambda: 4)
+ state["groups_ctx"] = {}
+ page = (await ops.list_groups(state))["settings"]
+ assert page["cpu_count"] == 4
+ assert page == await ops.get_node_settings(state)
+
+
+@pytest.mark.asyncio
@pytest.mark.parametrize("value", [0, -1, 5, "many", True])
async def test_a_number_the_machine_cannot_honour_is_refused(state, monkeypatch, value):
monkeypatch.setattr("meshbay_node.ops.settings.max_processes", lambda: 4)