Skip to content

Commit f8ba656

Browse files
authored
feat(control-ui): simplified settings experience for non-admin operators (#125492)
* test(control-ui): add --operator-scopes flag to the mock dev server * feat(control-ui): simplified settings experience for non-admin operators Non-admin browsers previously saw every settings page, many of which dead-ended or rendered enabled controls whose RPCs fail with 'missing scope: operator.admin'. - config.schema drops from operator.admin to operator.read: the schema is a static document describing options whose values are already readable via read-scoped config.get; admin-only schema only broke read-only settings rendering (Automation/Infrastructure/AI Agents/Communications showed 'Schema unavailable. Use Raw.'). - Settings sidebar and settings search hide admin-only routes (custodian, labs, updates, automation, infrastructure, mcp, security, secrets, cloud-workers, communications, ai-agents, model-setup) for non-admin viewers; legacy gateways without advertised scopes keep the full UI. - Channels, Devices, Worktrees, Memory Import, Profile gate their mutation controls on actual scopes with 'Browsing only…' notices instead of enabled-but-failing buttons; Devices no longer fires device.pair.list / exec.approvals.get without the scopes to call them (kills the two red error callouts on page load). - Scope-upgrade banner: dismissing it in the guidance phase (no in-app upgrade path) now hides it fully instead of leaving a permanent chip. - Config write coordinator surfaces scope refusals as a visible admin-required error instead of silently resolving false. * test(control-ui): advertise config.schema in the mock dev gateway ensureSchemaLoaded now checks method advertisement + scope before loading the schema; the mock harness must advertise config.schema like a real gateway does or schema-driven settings pages render empty in the mock. * fix(control-ui): close the worktree create draft on scope downgrade * perf(doctor): isolate memory health artifact Doctor lint loaded the broad Memory Core API barrel only to register health checks and read isolated check IDs. That synchronously pulled the full memory public graph into the first lint run, consuming most of the 120-second test budget. Load a dedicated doctor-health public artifact instead and verify it is packaged. The bisect boundary was 9de3ca5 (#125571); because that commit only adds upgrade-test assets, it exposed a pre-existing runner-sensitive cost rather than introducing the expensive import path. * test(control-ui): restore device lifecycle test boundary * perf(control-ui): lazy-load settings sidebar * fix(ui): recheck access after confirmations * fix(control-ui): gate presence-driven device reloads on pairing access The presence connectivity-change path still called device.pair.list without operator.pairing, the same invariant the pair-event and poller paths already guard; a limited browser got a doomed RPC on every connectivity change. * fix(control-ui): fail open on schema loads for legacy scope-less gateways canCallGatewayMethod hardened to strict advertisement+scope checks (#125478), which made the new ensureSchemaLoaded gate silently skip config.schema for legacy hellos without advertised scopes or a method list. Schema loads now skip only on a definitive denial (method advertised absent, or advertised scopes without operator.read), reusing the fail-open hasOperatorReadAccess semantics the rest of the non-admin UI uses; regression test pins the legacy snapshot path. * test(control-ui): split schema-access coverage into its own file runtime-config-capability.test.ts crossed the max-lines cap; the legacy fail-open regression and its denial counterpart move to a colocated schema-access test file. * fix(scripts): keep mapped Vitest lanes at their measured no-output floor The codex extension shard legitimately works in silence beyond 300s under the default reporter (measured 61s import + 293s testing at ~95% CPU); the CI-wide OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS=300000 env override shrank the lane below that and the watchdog killed healthy runs, flipping with incidental flake output (#125825). Per-config entries in VITEST_CONFIG_NO_OUTPUT_TIMEOUT_MS now act as measured silence floors: a global env value may widen a mapped lane's window but no longer shrinks it; unmapped configs and the explicit '0' disable keep env verbatim. Adds the codex extension lane to the map at the extra-long tier (same class as the discord entry from #123025).
1 parent b9d0120 commit f8ba656

55 files changed

Lines changed: 1195 additions & 161 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export {
2+
MEMORY_MANAGED_LOCAL_EMBEDDING_SETUP_CHECK_ID,
3+
pluginStateIsolatedDoctorCheckIds,
4+
registerMemoryCoreDoctorChecks,
5+
} from "./src/doctor-health.js";

‎scripts/control-ui-mock-dev.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ type CliOptions = {
4141
allowedHosts: string[];
4242
fixture?: "approval" | "board" | "swarm" | "workboard";
4343
host: string;
44+
operatorScopes?: string[];
4445
port: number;
4546
};
4647

@@ -155,6 +156,10 @@ function parseArgs(args: string[]): CliOptions {
155156
options.port = parsePort(args[++i], options.port);
156157
} else if (arg.startsWith("--port=")) {
157158
options.port = parsePort(arg.slice("--port=".length), options.port);
159+
} else if (arg === "--operator-scopes") {
160+
options.operatorScopes = parseOperatorScopes(args[++i]);
161+
} else if (arg.startsWith("--operator-scopes=")) {
162+
options.operatorScopes = parseOperatorScopes(arg.slice("--operator-scopes=".length));
158163
}
159164
}
160165
return options;
@@ -175,6 +180,14 @@ function parsePort(value: string | undefined, fallback: number): number {
175180
return Number.isInteger(parsed) && parsed > 0 && parsed < 65_536 ? parsed : fallback;
176181
}
177182

183+
function parseOperatorScopes(value: string | undefined): string[] | undefined {
184+
const scopes = (value ?? "")
185+
.split(",")
186+
.map((scope) => scope.trim())
187+
.filter(Boolean);
188+
return scopes.length > 0 ? scopes : undefined;
189+
}
190+
178191
function sessionRow(
179192
key: string,
180193
label: string,
@@ -1631,6 +1644,7 @@ async function createChatPickerScenario(
16311644
featureMethods: [
16321645
"browser.request",
16331646
"chat.abort",
1647+
"config.schema",
16341648
"chat.metadata",
16351649
"chat.startup",
16361650
"question.list",
@@ -2850,6 +2864,9 @@ async function waitForShutdown(): Promise<void> {
28502864

28512865
const options = parseArgs(process.argv.slice(2));
28522866
const scenario = await createChatPickerScenario(options.fixture);
2867+
if (options.operatorScopes) {
2868+
scenario.operatorScopes = options.operatorScopes;
2869+
}
28532870
const server = await createServer({
28542871
base: "/",
28552872
cacheDir: path.join(repoRoot, ".artifacts", "control-ui-mock-vite"),

‎scripts/run-vitest.mts‎

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@ export const VITEST_CONFIG_NO_OUTPUT_TIMEOUT_MS = new Map([
9191
"test/vitest/vitest.extension-discord.config.ts",
9292
DEFAULT_EXTRA_LONG_RUNNING_VITEST_NO_OUTPUT_TIMEOUT_MS,
9393
],
94+
// Codex extension shard: 168 serial files run ~6min total with silent
95+
// stretches beyond 300s under the default reporter (measured 61s import +
96+
// 293s testing while the worker burned ~95% CPU); the 300s CI window kills
97+
// healthy runs and flips with incidental flake output (#125825).
98+
[
99+
"test/vitest/vitest.extension-codex.config.ts",
100+
DEFAULT_EXTRA_LONG_RUNNING_VITEST_NO_OUTPUT_TIMEOUT_MS,
101+
],
94102
[GATEWAY_CORE_VITEST_CONFIG, DEFAULT_EXTRA_LONG_RUNNING_VITEST_NO_OUTPUT_TIMEOUT_MS],
95103
[GATEWAY_SERVER_VITEST_CONFIG, DEFAULT_EXTRA_LONG_RUNNING_VITEST_NO_OUTPUT_TIMEOUT_MS],
96104
]);
@@ -509,13 +517,28 @@ export function resolveRunVitestSpawnEnv(
509517
}
510518
const defaultTimeoutMs = resolveDefaultVitestNoOutputTimeoutMs(argv);
511519
const hasTimeout = Object.hasOwn(baseEnv, VITEST_NO_OUTPUT_TIMEOUT_ENV_KEY);
512-
const timeoutMs = hasTimeout
520+
const envTimeoutMs = hasTimeout
513521
? parsePositiveInt(baseEnv[VITEST_NO_OUTPUT_TIMEOUT_ENV_KEY])
522+
: null;
523+
// Per-config entries in VITEST_CONFIG_NO_OUTPUT_TIMEOUT_MS are measured
524+
// silence floors for healthy lanes; a global env value (CI sets one for
525+
// every shard) may widen a mapped lane's window but must not shrink it
526+
// below its floor, or the watchdog kills legitimately quiet runs
527+
// (#125825). Unmapped configs keep the env value verbatim.
528+
const configArg = resolveVitestConfigArg(argv);
529+
const configFloorMs = configArg === null ? null : resolveVitestConfigNoOutputTimeoutMs(configArg);
530+
// An explicitly disabled or unparsable env value (e.g. "0") stays verbatim.
531+
const timeoutMs = hasTimeout
532+
? envTimeoutMs === null || configFloorMs === null
533+
? envTimeoutMs
534+
: Math.max(envTimeoutMs, configFloorMs)
514535
: defaultTimeoutMs;
515536
const hasHeartbeat = Object.hasOwn(baseEnv, VITEST_NO_OUTPUT_HEARTBEAT_ENV_KEY);
516537
return {
517538
...baseEnv,
518-
...(!hasTimeout ? { [VITEST_NO_OUTPUT_TIMEOUT_ENV_KEY]: String(defaultTimeoutMs) } : {}),
539+
...(timeoutMs !== null && timeoutMs !== envTimeoutMs
540+
? { [VITEST_NO_OUTPUT_TIMEOUT_ENV_KEY]: String(timeoutMs) }
541+
: {}),
519542
...(!hasHeartbeat && timeoutMs !== null && DEFAULT_VITEST_NO_OUTPUT_HEARTBEAT_MS < timeoutMs
520543
? { [VITEST_NO_OUTPUT_HEARTBEAT_ENV_KEY]: String(DEFAULT_VITEST_NO_OUTPUT_HEARTBEAT_MS) }
521544
: {}),

‎src/flows/bundled-health-checks.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ describe("registerBundledHealthChecks", () => {
140140

141141
expect(mocks.loadBundledPluginPublicArtifactModuleSync).toHaveBeenCalledWith({
142142
dirName: "memory-core",
143-
artifactBasename: "api.js",
143+
artifactBasename: "doctor-health-api.js",
144144
});
145145
expect(mocks.loadBundledPluginPublicArtifactModuleSync).not.toHaveBeenCalledWith(
146146
expect.objectContaining({ dirName: "llama-cpp" }),

‎src/flows/bundled-health-checks.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ type BundledHealthCheckPluginStateMode = "direct" | "deferred" | "isolated";
6060
function loadMemoryCoreHealthApi(): BundledHealthApi {
6161
return loadBundledPluginPublicArtifactModuleSync<BundledHealthApi>({
6262
dirName: "memory-core",
63-
artifactBasename: "api.js",
63+
artifactBasename: "doctor-health-api.js",
6464
});
6565
}
6666

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ describe("method scope resolution", () => {
148148
["secrets.store.delete", ["operator.admin"]],
149149
["tools.github.status", ["operator.read"]],
150150
["tools.github.configure", ["operator.admin"]],
151-
["config.schema", ["operator.admin"]],
151+
["config.schema", ["operator.read"]],
152152
["config.patch", ["operator.admin"]],
153153
["nativeHook.invoke", ["operator.admin"]],
154154
["wizard.start", ["operator.admin"]],
@@ -731,7 +731,7 @@ describe("operator scope authorization", () => {
731731
["health", ["operator.read"], { allowed: true }],
732732
["health", ["operator.write"], { allowed: true }],
733733
["config.schema.lookup", ["operator.read"], { allowed: true }],
734-
["config.schema", ["operator.read"], { allowed: false, missingScope: "operator.admin" }],
734+
["config.schema", ["operator.read"], { allowed: true }],
735735
["config.patch", ["operator.admin"], { allowed: true }],
736736
])("authorizes %s for scopes %j", (method, scopes, expected) => {
737737
expect(authorizeOperatorScopesForMethod(method, scopes)).toEqual(expected);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const CORE_GATEWAY_METHOD_SPECS = [
6565
["config.set", "config", "operator.admin", "<=2026.7"],
6666
["config.apply", "config", "operator.admin", "<=2026.7", { controlPlaneWrite: true }],
6767
["config.patch", "config", "operator.admin", "<=2026.7", { controlPlaneWrite: true }],
68-
["config.schema", "config", "operator.admin", "<=2026.7"],
68+
["config.schema", "config", "operator.read", "<=2026.7"],
6969
["config.schema.lookup", "config", "operator.read", "<=2026.7"],
7070
["exec.approvals.get", "exec-approvals", "operator.admin", "<=2026.7"],
7171
["exec.approvals.set", "exec-approvals", "operator.admin", "<=2026.7"],

‎src/gateway/server.auth.default-token.suite.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,9 @@ export function registerDefaultAuthTokenSuite(): void {
384384
"role",
385385
"scopes",
386386
]);
387-
const admin = await rpcReq(wsReconnect, "config.schema");
387+
const schema = await rpcReq(wsReconnect, "config.schema");
388+
expect(schema.ok).toBe(true);
389+
const admin = await rpcReq(wsReconnect, "config.patch");
388390
expect(admin.ok).toBe(false);
389391
expect(admin.error?.message).toBe("missing scope: operator.admin");
390392
} finally {

‎src/plugins/bundled-plugin-metadata.test.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,15 @@ describe("bundled plugin metadata", () => {
431431
});
432432
});
433433

434+
it("keeps Memory Core's health checks on a narrow public surface", () => {
435+
const memoryCore = listRepoBundledPluginMetadata().find(
436+
(entry) => entry.dirName === "memory-core",
437+
);
438+
expectArtifactPresence(memoryCore?.publicSurfaceArtifacts, {
439+
contains: ["doctor-health-api.js"],
440+
});
441+
});
442+
434443
it("keeps iMessage message-tool discovery on a narrow public surface", () => {
435444
const imessage = listRepoBundledPluginMetadata().find((entry) => entry.dirName === "imessage");
436445
expectArtifactPresence(imessage?.publicSurfaceArtifacts, {

‎test/scripts/run-vitest.test.ts‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,29 @@ describe("scripts/run-vitest", () => {
643643
});
644644
});
645645

646+
it("keeps mapped configs at their measured silence floor when env is smaller", () => {
647+
expect(
648+
resolveRunVitestSpawnEnv(
649+
{ OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS: "300000", PATH: "/usr/bin" },
650+
["run", "--config", "test/vitest/vitest.extension-codex.config.ts"],
651+
),
652+
).toEqual({
653+
OPENCLAW_VITEST_NO_OUTPUT_HEARTBEAT_MS: "30000",
654+
OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS: "2400000",
655+
PATH: "/usr/bin",
656+
});
657+
expect(
658+
resolveRunVitestSpawnEnv(
659+
{ OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS: "300000", PATH: "/usr/bin" },
660+
["run", "--config", "test/vitest/vitest.unit.config.ts"],
661+
),
662+
).toEqual({
663+
OPENCLAW_VITEST_NO_OUTPUT_HEARTBEAT_MS: "30000",
664+
OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS: "300000",
665+
PATH: "/usr/bin",
666+
});
667+
});
668+
646669
it("disables an inherited Node compile cache for every Vitest child", () => {
647670
expect(
648671
resolveRunVitestSpawnEnv(

0 commit comments

Comments
 (0)