Merge pull request #122 from pikasTech/fix/code-queue-health-remote-compact
fix: compact remote code queue health
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { summarizeMicroserviceHealthResponse } from "./src/microservices";
|
||||
import { summarizeRemoteMicroserviceResponse } from "./src/remote";
|
||||
|
||||
type JsonRecord = Record<string, unknown>;
|
||||
|
||||
@@ -102,6 +103,8 @@ const fixture = largeCodeQueueHealth();
|
||||
const compact = asRecord(summarizeMicroserviceHealthResponse(fixture, ["health", "code-queue"], "code-queue"));
|
||||
const raw = summarizeMicroserviceHealthResponse(fixture, ["health", "code-queue", "--raw"], "code-queue");
|
||||
const full = summarizeMicroserviceHealthResponse(fixture, ["health", "code-queue", "--full"], "code-queue");
|
||||
const remoteCompact = asRecord(summarizeRemoteMicroserviceResponse("health", "code-queue", fixture, ["microservice", "health", "code-queue"]));
|
||||
const remoteRaw = summarizeRemoteMicroserviceResponse("health", "code-queue", fixture, ["microservice", "health", "code-queue", "--raw"]);
|
||||
const unhealthyWrapper = asRecord(summarizeMicroserviceHealthResponse({
|
||||
ok: false,
|
||||
status: 503,
|
||||
@@ -137,6 +140,8 @@ assertCondition(liveness.effectiveLiveness === "live" && liveness.splitBrainLive
|
||||
assertCondition(String(liveness.interpretation).includes("continue supervision"), "compact liveness includes commander interpretation", liveness);
|
||||
assertCondition(typeof outputPolicy.rawCommand === "string" && String(outputPolicy.rawCommand).includes("--raw"), "compact output exposes raw drill-down command", outputPolicy);
|
||||
assertCondition(raw === fixture && full === fixture, "--raw/--full must preserve full health access", { rawSame: raw === fixture, fullSame: full === fixture });
|
||||
assertCondition(!("body" in remoteCompact) && asRecord(remoteCompact.queue).runningCount === 5, "remote frontend health must reuse compact code-queue summary by default", remoteCompact);
|
||||
assertCondition(remoteRaw === fixture, "remote frontend health --raw must preserve full diagnostics", { remoteRawSame: remoteRaw === fixture });
|
||||
assertCondition(unhealthyWrapper.ok === false && unhealthyWrapper.reason === "health body ok=false", "unhealthy wrapper keeps probe failure", unhealthyWrapper);
|
||||
assertCondition(unhealthyQueue.runningCount === 5 && unhealthyLiveness.effectiveLiveness === "live", "unhealthy wrapper still surfaces upstream queue liveness", { unhealthyQueue, unhealthyLiveness });
|
||||
|
||||
@@ -146,6 +151,7 @@ console.log(JSON.stringify({
|
||||
"default code-queue health output is compact and omits raw body/queue dumps",
|
||||
"critical ok/status/service/running/heartbeat/liveness fields remain visible",
|
||||
"unhealthy backend health wrapper still surfaces upstream code-queue liveness",
|
||||
"remote frontend microservice health uses the same compact/raw policy",
|
||||
"--raw and --full return the original health response for diagnostics",
|
||||
],
|
||||
compactChars: compactBody.length,
|
||||
|
||||
+10
-2
@@ -1,7 +1,7 @@
|
||||
import { spawn } from "node:child_process";
|
||||
import { type UniDeskConfig } from "./config";
|
||||
import { type DebugDispatchCommand, isDebugDispatchCommand } from "./debug";
|
||||
import { summarizeMicroserviceProxyResponse } from "./microservices";
|
||||
import { summarizeMicroserviceHealthResponse, summarizeMicroserviceObservation, summarizeMicroserviceProxyResponse } from "./microservices";
|
||||
import { parseNetworkPerfOptions, runNetworkPerf } from "./network-perf";
|
||||
import { isSshSkillDiscoveryArgs, parseSshArgs } from "./ssh";
|
||||
import { codexJudgeQueryAsync, codexOutputQueryAsync, codexPrPreflightQueryAsync, codexTaskQueryAsync, codexTasksQueryAsync } from "./code-queue";
|
||||
@@ -618,6 +618,13 @@ async function remoteDebugTask(session: FrontendSession, args: string[]): Promis
|
||||
return { transport: "frontend", tasksResponse, taskId, task: task ?? null };
|
||||
}
|
||||
|
||||
export function summarizeRemoteMicroserviceResponse(action: string, id: string, response: unknown, args: string[]): unknown {
|
||||
const optionArgs = args.slice(3);
|
||||
if (action === "health") return summarizeMicroserviceHealthResponse(response, optionArgs, id);
|
||||
if (action === "status" || action === "diagnostics") return summarizeMicroserviceObservation(action, id, response, optionArgs);
|
||||
return response;
|
||||
}
|
||||
|
||||
async function remoteMicroservice(session: FrontendSession, args: string[]): Promise<unknown> {
|
||||
const action = args[1] ?? "list";
|
||||
const id = args[2];
|
||||
@@ -626,9 +633,10 @@ async function remoteMicroservice(session: FrontendSession, args: string[]): Pro
|
||||
return { transport: "frontend", response: await frontendJson(session, "/api/microservices", undefined, 12_000) };
|
||||
}
|
||||
if ((action === "status" || action === "health" || action === "diagnostics" || action === "tunnel-self-test") && id !== undefined) {
|
||||
const response = await frontendJson(session, `/api/microservices/${encodeURIComponent(id)}/${action}`, undefined, 18_000);
|
||||
return {
|
||||
transport: "frontend",
|
||||
response: await frontendJson(session, `/api/microservices/${encodeURIComponent(id)}/${action}`, undefined, 18_000),
|
||||
response: summarizeRemoteMicroserviceResponse(action, id, response, args),
|
||||
};
|
||||
}
|
||||
if (action === "proxy" && id !== undefined && path !== undefined && path.startsWith("/")) {
|
||||
|
||||
Reference in New Issue
Block a user