Skip to content

Commit ad475ce

Browse files
authored
feat(gateway/ui): command-lane diagnostics with debug page table and global busyness overlay (#125591)
* feat(gateway): expose command lane diagnostics * feat(ui): add live debug busyness overlay * fix(ui): show newest events in debug overlay and update diagnostics call-list tests * test(ui): add lane and status fixtures to the mocked dashboard * feat(ui): add System busyness entry to the account menu * fix(gateway/ui): bound lane diagnostics, append-only descriptor, fail-visible lanes load Addresses ClawSweeper review findings on #125591: diagnostics.lanes moves to the append-only tail of the descriptor table, the Control UI lanes request fails visibly instead of masking errors, and the RPC exports only static lane snapshots plus a bounded dynamic-session aggregate composed in the new command-lane-diagnostics module. * chore(protocol): regenerate Kotlin gateway methods for diagnostics.lanes * test(gateway/ui): register diagnostics.lanes in the 2026.8 train and mock it in the debug e2e
1 parent 43e0150 commit ad475ce

31 files changed

Lines changed: 1255 additions & 13 deletions

‎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
@@ -591,6 +591,7 @@ enum class GatewayMethod(
591591
ProgressCardPut("progressCard.put"),
592592
ToolsGithubStatus("tools.github.status"),
593593
ToolsGithubConfigure("tools.github.configure"),
594+
DiagnosticsLanes("diagnostics.lanes"),
594595
}
595596

596597
enum class GatewayEvent(

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

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2442,6 +2442,82 @@ async function createChatPickerScenario(
24422442
},
24432443
],
24442444
},
2445+
// Saturated-main fixture so the debug page and overlay render queued and
2446+
// group-budget states, not just idle lanes.
2447+
"diagnostics.lanes": {
2448+
ts: baseTime,
2449+
lanes: [
2450+
{
2451+
lane: "cron",
2452+
queuedCount: 0,
2453+
activeCount: 1,
2454+
maxConcurrent: 4,
2455+
draining: false,
2456+
generation: 1,
2457+
},
2458+
{
2459+
lane: "cron-nested",
2460+
queuedCount: 0,
2461+
activeCount: 1,
2462+
maxConcurrent: 4,
2463+
draining: false,
2464+
generation: 1,
2465+
group: "cron-hooks",
2466+
groupActive: 2,
2467+
groupBudget: 4,
2468+
},
2469+
{
2470+
lane: "hook-dispatch",
2471+
queuedCount: 2,
2472+
activeCount: 1,
2473+
maxConcurrent: 4,
2474+
draining: false,
2475+
generation: 1,
2476+
group: "cron-hooks",
2477+
groupActive: 2,
2478+
groupBudget: 4,
2479+
reservedForLane: 1,
2480+
blockedBy: "group-budget",
2481+
},
2482+
{
2483+
lane: "main",
2484+
queuedCount: 3,
2485+
activeCount: 16,
2486+
maxConcurrent: 16,
2487+
draining: false,
2488+
generation: 7,
2489+
blockedBy: "lane",
2490+
},
2491+
{
2492+
lane: "nested",
2493+
queuedCount: 0,
2494+
activeCount: 0,
2495+
maxConcurrent: 1,
2496+
draining: false,
2497+
generation: 1,
2498+
},
2499+
{
2500+
lane: "subagent",
2501+
queuedCount: 5,
2502+
activeCount: 8,
2503+
maxConcurrent: 8,
2504+
draining: false,
2505+
generation: 4,
2506+
blockedBy: "lane",
2507+
},
2508+
],
2509+
dynamic: {
2510+
laneCount: 23,
2511+
activeCount: 9,
2512+
queuedCount: 4,
2513+
queuedLaneCount: 3,
2514+
},
2515+
},
2516+
status: {
2517+
eventLoop: { utilization: 0.42, delayP99Ms: 12, delayMaxMs: 87 },
2518+
uptimeMs: 5_412_000,
2519+
},
2520+
"last-heartbeat": { ts: baseTime },
24452521
"sessions.list": {
24462522
cases: [
24472523
// Child fetches must precede the catch-all page case (subset match).

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ describe("method scope resolution", () => {
118118
["session.discussion.open", ["operator.write"]],
119119
["environments.status", ["operator.read"]],
120120
["diagnostics.stability", ["operator.read"]],
121+
["diagnostics.lanes", ["operator.read"]],
121122
["gateway.restart.preflight", ["operator.read"]],
122123
["skills.curator.status", ["operator.read"]],
123124
["hooks.status", ["operator.read"]],

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ const TRAIN_2026_7_METHODS = [
8181
] as const;
8282

8383
const CURRENT_TRAIN_METHODS = [
84+
"diagnostics.lanes",
8485
"device.pair.setupStatus",
8586
"sessions.patchMany",
8687
"sessions.groups.update",

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ const CORE_GATEWAY_METHOD_SPECS = [
552552
"2026.8",
553553
{ controlPlaneWrite: true },
554554
],
555+
["diagnostics.lanes", "diagnostics", "operator.read", "2026.8"],
555556
] as const satisfies readonly CoreGatewayMethodSpecRow[];
556557

557558
export type CoreGatewayHandlerFamily = Exclude<(typeof CORE_GATEWAY_METHOD_SPECS)[number][1], null>;

‎src/gateway/server-methods-list.test.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ describe("listGatewayMethods", () => {
7272
});
7373

7474
it("appends new methods after model probing without shifting older method indices", () => {
75-
expect(listGatewayMethods().slice(-59)).toEqual([
75+
expect(listGatewayMethods().slice(-60)).toEqual([
7676
"models.probe",
7777
"migrations.memory.plan",
7878
"migrations.memory.apply",
@@ -132,6 +132,7 @@ describe("listGatewayMethods", () => {
132132
"progressCard.put",
133133
"tools.github.status",
134134
"tools.github.configure",
135+
"diagnostics.lanes",
135136
]);
136137
const methods = listGatewayMethods();
137138
expect(methods.indexOf("node.pluginSurface.refresh")).toBe(
@@ -237,7 +238,7 @@ describe("listGatewayMethods", () => {
237238
"exec.approval.get",
238239
]);
239240
expect(methods).toContain("tts.speak");
240-
expect(coreMethods.slice(-66)).toEqual([
241+
expect(coreMethods.slice(-67)).toEqual([
241242
"sessions.catalog.continue",
242243
"sessions.catalog.archive",
243244
"approval.get",
@@ -304,6 +305,7 @@ describe("listGatewayMethods", () => {
304305
"progressCard.put",
305306
"tools.github.status",
306307
"tools.github.configure",
308+
"diagnostics.lanes",
307309
]);
308310
expect(methods.indexOf("approval.get")).toBeGreaterThan(methods.indexOf("tts.speak"));
309311
expect(methods.indexOf("approval.resolve")).toBe(methods.indexOf("approval.get") + 1);

‎src/gateway/server-methods/diagnostics.test.ts‎

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,36 @@ import {
1313
startDiagnosticStabilityRecorder,
1414
stopDiagnosticStabilityRecorder,
1515
} from "../../logging/diagnostic-stability.js";
16+
import { getCommandLaneDiagnostics } from "../../process/command-lane-diagnostics.js";
17+
import {
18+
enqueueCommandInLane,
19+
getCommandLaneSnapshot,
20+
setCommandLaneConcurrency,
21+
} from "../../process/command-queue.js";
22+
import { CommandLane } from "../../process/lanes.js";
1623
import { diagnosticsHandlers } from "./diagnostics.js";
1724

25+
type LaneDiagnosticsPayload = {
26+
ts: number;
27+
} & ReturnType<typeof getCommandLaneDiagnostics>;
28+
29+
async function requestLaneDiagnostics(): Promise<LaneDiagnosticsPayload> {
30+
const respond = vi.fn();
31+
await expectDefined(
32+
diagnosticsHandlers["diagnostics.lanes"],
33+
'diagnosticsHandlers["diagnostics.lanes"] test invariant',
34+
)({
35+
req: { type: "req", id: "lanes", method: "diagnostics.lanes", params: {} },
36+
params: {},
37+
client: null,
38+
isWebchatConnect: () => false,
39+
context: {} as never,
40+
respond,
41+
});
42+
expect(respond).toHaveBeenCalledTimes(1);
43+
return respond.mock.calls[0]?.[1] as LaneDiagnosticsPayload;
44+
}
45+
1846
describe("diagnostics gateway methods", () => {
1947
beforeEach(() => {
2048
resetDiagnosticStabilityRecorderForTest();
@@ -130,4 +158,96 @@ describe("diagnostics gateway methods", () => {
130158
],
131159
]);
132160
});
161+
162+
it("returns every static command lane in sorted order with live capacity counts", async () => {
163+
const lane = CommandLane.SkillWorkshopReview;
164+
const originalConcurrency = getCommandLaneSnapshot(lane).maxConcurrent;
165+
setCommandLaneConcurrency(lane, 1);
166+
167+
let releaseActive!: () => void;
168+
let markActive!: () => void;
169+
const activeStarted = new Promise<void>((resolve) => {
170+
markActive = resolve;
171+
});
172+
const activeRelease = new Promise<void>((resolve) => {
173+
releaseActive = resolve;
174+
});
175+
const active = enqueueCommandInLane(lane, async () => {
176+
markActive();
177+
await activeRelease;
178+
});
179+
await activeStarted;
180+
const queued = enqueueCommandInLane(lane, async () => undefined);
181+
182+
try {
183+
const payload = await requestLaneDiagnostics();
184+
expect(payload.ts).toBeGreaterThan(0);
185+
expect(payload.lanes.map((snapshot) => snapshot.lane)).toEqual([
186+
CommandLane.Cron,
187+
CommandLane.CronNested,
188+
CommandLane.HookDispatch,
189+
CommandLane.Main,
190+
CommandLane.Nested,
191+
CommandLane.SkillWorkshopReview,
192+
CommandLane.Subagent,
193+
CommandLane.SystemAgent,
194+
]);
195+
expect(payload.lanes).toEqual(
196+
expect.arrayContaining([
197+
expect.objectContaining({
198+
lane,
199+
activeCount: 1,
200+
queuedCount: 1,
201+
maxConcurrent: 1,
202+
blockedBy: "lane",
203+
}),
204+
]),
205+
);
206+
} finally {
207+
releaseActive();
208+
await Promise.all([active, queued]);
209+
setCommandLaneConcurrency(lane, originalConcurrency);
210+
}
211+
});
212+
213+
it("aggregates saturated dynamic session lanes without exporting their names", async () => {
214+
const lane = `session:test-${Date.now()}`;
215+
const before = await requestLaneDiagnostics();
216+
setCommandLaneConcurrency(lane, 1);
217+
218+
let releaseActive!: () => void;
219+
let markActive!: () => void;
220+
const activeStarted = new Promise<void>((resolve) => {
221+
markActive = resolve;
222+
});
223+
const activeRelease = new Promise<void>((resolve) => {
224+
releaseActive = resolve;
225+
});
226+
const active = enqueueCommandInLane(lane, async () => {
227+
markActive();
228+
await activeRelease;
229+
});
230+
await activeStarted;
231+
const queued = enqueueCommandInLane(lane, async () => undefined);
232+
233+
try {
234+
const payload = await requestLaneDiagnostics();
235+
const baseline = before.dynamic ?? {
236+
laneCount: 0,
237+
activeCount: 0,
238+
queuedCount: 0,
239+
queuedLaneCount: 0,
240+
};
241+
expect(payload.lanes.map((snapshot) => snapshot.lane)).not.toContain(lane);
242+
expect(payload.dynamic).toEqual({
243+
laneCount: baseline.laneCount + 1,
244+
activeCount: baseline.activeCount + 1,
245+
queuedCount: baseline.queuedCount + 1,
246+
queuedLaneCount: baseline.queuedLaneCount + 1,
247+
});
248+
} finally {
249+
releaseActive();
250+
await Promise.all([active, queued]);
251+
}
252+
});
133253
});

‎src/gateway/server-methods/diagnostics.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@ import {
55
getDiagnosticStabilitySnapshot,
66
normalizeDiagnosticStabilityQuery,
77
} from "../../logging/diagnostic-stability.js";
8+
import { getCommandLaneDiagnostics } from "../../process/command-lane-diagnostics.js";
89
import type { GatewayRequestHandlers } from "./types.js";
910

1011
/** Gateway handler for payload-free stability diagnostics. */
1112
export const diagnosticsHandlers: GatewayRequestHandlers = {
13+
"diagnostics.lanes": ({ respond }) => {
14+
respond(true, { ts: Date.now(), ...getCommandLaneDiagnostics() }, undefined);
15+
},
1216
"diagnostics.stability": async ({ params, respond }) => {
1317
try {
1418
// Normalization owns parameter bounds so malformed diagnostic requests
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Bounded diagnostics composition over the command queue's lane totals.
2+
// Static lanes get full snapshots; per-session (dynamic) lanes collapse into
3+
// one aggregate so a saturation snapshot can never become an unbounded payload.
4+
import {
5+
type CommandLaneSnapshot,
6+
getCommandLaneSnapshot,
7+
listCommandLaneTotals,
8+
} from "./command-queue.js";
9+
import { STATIC_COMMAND_LANES } from "./lanes.js";
10+
11+
type DynamicCommandLaneSummary = {
12+
laneCount: number;
13+
activeCount: number;
14+
queuedCount: number;
15+
queuedLaneCount: number;
16+
};
17+
18+
const STATIC_COMMAND_LANE_SET: ReadonlySet<string> = new Set(STATIC_COMMAND_LANES);
19+
20+
export function getCommandLaneDiagnostics(): {
21+
lanes: CommandLaneSnapshot[];
22+
dynamic: DynamicCommandLaneSummary | null;
23+
} {
24+
const lanes = [...STATIC_COMMAND_LANES].toSorted().map((lane) => getCommandLaneSnapshot(lane));
25+
const dynamic: DynamicCommandLaneSummary = {
26+
laneCount: 0,
27+
activeCount: 0,
28+
queuedCount: 0,
29+
queuedLaneCount: 0,
30+
};
31+
for (const totals of listCommandLaneTotals()) {
32+
if (STATIC_COMMAND_LANE_SET.has(totals.lane)) {
33+
continue;
34+
}
35+
dynamic.laneCount += 1;
36+
dynamic.activeCount += totals.activeCount;
37+
dynamic.queuedCount += totals.queuedCount;
38+
if (totals.queuedCount > 0) {
39+
dynamic.queuedLaneCount += 1;
40+
}
41+
}
42+
return { lanes, dynamic: dynamic.laneCount > 0 ? dynamic : null };
43+
}

‎src/process/command-queue.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,19 @@ export function getCommandLaneSnapshot(lane: string = CommandLane.Main): Command
681681
return createCommandLaneSnapshot(state);
682682
}
683683

684+
/** Per-lane work totals for every live lane; diagnostics composition lives in command-lane-diagnostics.ts. */
685+
export function listCommandLaneTotals(): Array<{
686+
lane: string;
687+
activeCount: number;
688+
queuedCount: number;
689+
}> {
690+
return [...getQueueState().lanes.values()].map((state) => ({
691+
lane: state.lane,
692+
activeCount: state.activeTaskIds.size,
693+
queuedCount: state.queue.length,
694+
}));
695+
}
696+
684697
/**
685698
* Active task ids for a lane. Ids are process-monotonic, so recovery can
686699
* detect a turn that started after a point in time it captured earlier.

0 commit comments

Comments
 (0)