Skip to content

Commit 5e67beb

Browse files
authored
feat(node-host): add negotiated private worker controls (#122939)
* feat(node-host): add private worker supervisor controls * refactor(node-host): harden private worker controls * refactor(node-host): simplify private worker controls * docs(plan): track private worker controls * fix(node-host): satisfy private control CI guards * test(gateway): follow worker service construction boundary * test(gateway): register private control release train * fix(gateway): retain worker dialect across reapproval
1 parent 9bf9bce commit 5e67beb

54 files changed

Lines changed: 2793 additions & 432 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewayProtocol.kt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ enum class GatewayMethod(
430430
NodePluginSurfaceRefresh("node.pluginSurface.refresh"),
431431
NodePluginToolsUpdate("node.pluginTools.update"),
432432
NodeSkillsUpdate("node.skills.update"),
433+
NodeProtocolFeaturesUpdate("node.protocolFeatures.update"),
433434
NodePendingDrain("node.pending.drain"),
434435
NodePendingEnqueue("node.pending.enqueue"),
435436
NodeInvoke("node.invoke"),

‎docs/plan/runners.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ advances a milestone.
2424
| 4 | Picker: grouping, placement, liveness, enrichment | in progress | #120804, #122531, #122635, #122774, #122923 |
2525
| F | Real-wire session boundary harness | landed | #121212 |
2626
| 5 | Public worker ingress path | landed | #122578, #122643 |
27-
| 6 | Node worker provider (device runners) | in progress | #122683, #122769, #122829 |
27+
| 6 | Node worker provider (device runners) | in progress | #122683, #122769, #122829, #122939 |
2828
| 7 | Bundle push consent + runner updates | not started | — |
2929
| 8 | Stop-and-continue moves | not started | — |
3030
| 9 | Deletions (ssh sandbox, openshell, exec-host clones, …) | not started | — |

‎src/gateway/method-scopes.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,7 @@ describe("core gateway method classification", () => {
866866
expect(isGatewayMethodClassified("node.pluginSurface.refresh")).toBe(true);
867867
expect(isGatewayMethodClassified("node.pluginTools.update")).toBe(true);
868868
expect(isGatewayMethodClassified("node.skills.update")).toBe(true);
869+
expect(isGatewayMethodClassified("node.protocolFeatures.update")).toBe(true);
869870
});
870871

871872
it("classifies every exposed core gateway handler method", () => {

‎src/gateway/methods/core-descriptors.since.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ const CURRENT_TRAIN_METHODS = [
101101
"desktop.launch",
102102
"device.scopes.requestUpgrade",
103103
"device.scopes.waitUpgrade",
104+
"node.protocolFeatures.update",
104105
] as const;
105106

106107
describe("core gateway method release trains", () => {

‎src/gateway/methods/core-descriptors.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ const CORE_GATEWAY_METHOD_SPECS = [
282282
["node.pluginSurface.refresh", "nodes", "node", "<=2026.7"],
283283
["node.pluginTools.update", "nodes", "node", "<=2026.7"],
284284
["node.skills.update", "nodes", "node", "<=2026.7"],
285+
["node.protocolFeatures.update", "nodes", "node", "2026.8", { advertise: false }],
285286
["node.pending.drain", "nodes-pending", "node", "<=2026.7"],
286287
["node.pending.enqueue", "nodes-pending", "operator.write", "<=2026.7"],
287288
// Params-aware: host-sensitive commands raise direct invocation from write to admin.

‎src/gateway/node-catalog.test.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Gateway node catalog regression tests.
33
*/
44
import { describe, expect, it } from "vitest";
5+
import { NODE_WORKER_SUPERVISOR_COMMANDS } from "../infra/node-commands.js";
56
import { createKnownNodeCatalog, getKnownNode, listKnownNodes } from "./node-catalog.js";
67

78
type CatalogInput = Parameters<typeof createKnownNodeCatalog>[0];
@@ -58,6 +59,21 @@ function pendingNode(overrides: Partial<TestPendingNode> = {}): TestPendingNode
5859
}
5960

6061
describe("gateway/node-catalog", () => {
62+
it("never projects private worker controls from persisted or pending state", () => {
63+
const catalog = createKnownNodeCatalog({
64+
pairedDevices: [pairedDevice()],
65+
pairedNodes: [pairedNode({ commands: ["system.run", ...NODE_WORKER_SUPERVISOR_COMMANDS] })],
66+
pendingNodes: [
67+
pendingNode({ commands: ["screen.snapshot", ...NODE_WORKER_SUPERVISOR_COMMANDS] }),
68+
],
69+
connectedNodes: [],
70+
});
71+
72+
const node = getKnownNode(catalog, "mac-1");
73+
expect(node?.commands).toEqual(["system.run"]);
74+
expect(node?.pendingDeclaredCommands).toEqual(["screen.snapshot"]);
75+
});
76+
6177
it("filters paired nodes by active node token instead of sticky historical roles", () => {
6278
const catalog = createKnownNodeCatalog({
6379
pairedDevices: [

‎src/gateway/node-catalog.ts‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
import { normalizeSortedUniqueTrimmedStringList } from "@openclaw/normalization-core/string-normalization";
88
import type { NodePairingPendingRequest, PairedDeviceNode } from "../infra/device-pairing-node.js";
99
import { hasEffectivePairedDeviceRole, type PairedDevice } from "../infra/device-pairing.js";
10+
import { filterPublicNodeCommands } from "../infra/node-commands.js";
1011
import {
1112
sameNodeApprovalSurfaceSet,
1213
sameNodePermissionSurface,
@@ -128,7 +129,7 @@ function buildApprovedNodeSource(entry: PairedDeviceNode): KnownNodeApprovedSour
128129
deviceFamily: entry.deviceFamily,
129130
modelIdentifier: entry.modelIdentifier,
130131
caps: entry.caps ?? [],
131-
commands: entry.commands ?? [],
132+
commands: filterPublicNodeCommands(entry.commands ?? []),
132133
permissions: entry.permissions,
133134
approvedAtMs: entry.approvedAtMs,
134135
lastConnectedAtMs: entry.lastConnectedAtMs,
@@ -152,7 +153,7 @@ function buildPendingNodeSource(entry: NodePairingPendingRequest): KnownNodePend
152153
deviceFamily: entry.deviceFamily,
153154
modelIdentifier: entry.modelIdentifier,
154155
caps: uniqueSortedStrings(entry.caps),
155-
commands: uniqueSortedStrings(entry.commands),
156+
commands: filterPublicNodeCommands(uniqueSortedStrings(entry.commands)),
156157
permissions: entry.permissions,
157158
};
158159
}
@@ -278,9 +279,9 @@ function buildEffectiveKnownNode(entry: {
278279
pendingNodePairing?.remoteIp,
279280
),
280281
caps: live ? uniqueSortedStrings(live.caps) : uniqueSortedStrings(nodePairing?.caps),
281-
commands: live
282-
? uniqueSortedStrings(live.commands)
283-
: uniqueSortedStrings(nodePairing?.commands),
282+
commands: filterPublicNodeCommands(
283+
live ? uniqueSortedStrings(live.commands) : uniqueSortedStrings(nodePairing?.commands),
284+
),
284285
nodePluginTools: live?.nodePluginTools,
285286
pathEnv: live?.pathEnv,
286287
permissions: live?.permissions ?? nodePairing?.permissions,

‎src/gateway/node-command-policy.test.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
GATEWAY_CLIENT_MODES,
88
} from "../../packages/gateway-protocol/src/client-info.js";
99
import type { OpenClawConfig } from "../config/types.openclaw.js";
10+
import { NODE_WORKER_SUPERVISOR_COMMANDS } from "../infra/node-commands.js";
1011
import { createEmptyPluginRegistry } from "../plugins/registry-empty.js";
1112
import { resetPluginRuntimeStateForTest, setActivePluginRegistry } from "../plugins/runtime.js";
1213
import { NODE_DESKTOP_STREAM_COMMAND } from "../shared/node-desktop-stream.js";
@@ -109,6 +110,25 @@ describe("gateway/node-command-policy", () => {
109110
).toEqual(["canvas.snapshot", "system.run"]);
110111
});
111112

113+
it("keeps private worker supervisor commands outside public policy", () => {
114+
const cfg = {
115+
gateway: { nodes: { commands: { allow: [...NODE_WORKER_SUPERVISOR_COMMANDS] } } },
116+
} as OpenClawConfig;
117+
const node = {
118+
platform: "linux",
119+
deviceFamily: "Linux",
120+
commands: [...NODE_WORKER_SUPERVISOR_COMMANDS],
121+
approvedCommands: [...NODE_WORKER_SUPERVISOR_COMMANDS],
122+
};
123+
124+
expect([...resolveNodeCommandAllowlist(cfg, node)]).not.toEqual(
125+
expect.arrayContaining([...NODE_WORKER_SUPERVISOR_COMMANDS]),
126+
);
127+
expect([...resolveNodePairingCommandAllowlist(cfg, node)]).not.toEqual(
128+
expect.arrayContaining([...NODE_WORKER_SUPERVISOR_COMMANDS]),
129+
);
130+
});
131+
112132
it("allows declared push-to-talk commands on trusted talk-capable nodes", () => {
113133
const cfg = {} as OpenClawConfig;
114134
for (const platform of ["ios", "android", "macos", "other"]) {

‎src/gateway/node-command-policy.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import {
1313
NODE_MCP_TOOLS_CALL_COMMAND,
1414
NODE_SYSTEM_NOTIFY_COMMAND,
1515
NODE_SYSTEM_RUN_COMMANDS,
16+
NODE_WORKER_SUPERVISOR_COMMANDS,
17+
isPrivateNodeInvokeCommand,
1618
} from "../infra/node-commands.js";
1719
import { getActivePluginGatewayNodePolicyRegistry } from "../plugins/runtime.js";
1820
import { NODE_DESKTOP_STREAM_COMMAND } from "../shared/node-desktop-stream.js";
@@ -444,6 +446,9 @@ function resolveNodeCommandAllowlistInternal(
444446
allow.delete(trimmed);
445447
}
446448
}
449+
for (const privateCommand of NODE_WORKER_SUPERVISOR_COMMANDS) {
450+
allow.delete(privateCommand);
451+
}
447452
return allow;
448453
}
449454

@@ -472,7 +477,7 @@ function normalizeDeclaredCommands(commands?: readonly string[]): string[] {
472477
const normalized: string[] = [];
473478
for (const value of commands) {
474479
const trimmed = value.trim();
475-
if (!trimmed || seen.has(trimmed)) {
480+
if (!trimmed || seen.has(trimmed) || isPrivateNodeInvokeCommand(trimmed)) {
476481
continue;
477482
}
478483
seen.add(trimmed);
@@ -499,6 +504,9 @@ export function isNodeCommandAllowed(params: {
499504
if (!command) {
500505
return { ok: false, reason: "command required" };
501506
}
507+
if (isPrivateNodeInvokeCommand(command)) {
508+
return { ok: false, reason: "command not allowlisted" };
509+
}
502510
if (!params.allowlist.has(command)) {
503511
return { ok: false, reason: "command not allowlisted" };
504512
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/** Unforgeable reason shared only by node-registry private pairing lifecycle owners. */
2+
export const NODE_INVOKE_PAIRING_CHANGED_ABORT = Symbol("nodeInvokePairingChanged");

0 commit comments

Comments
 (0)