From 5ec68f06712bcbbcd30f5618c22c39187e713642 Mon Sep 17 00:00:00 2001 From: Codex Date: Thu, 21 May 2026 09:42:16 +0000 Subject: [PATCH] fix: improve artifact preflight remote polling --- ...publish-user-service-preflight-contract-test.ts | 2 ++ scripts/src/remote.ts | 14 +++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/scripts/ci-publish-user-service-preflight-contract-test.ts b/scripts/ci-publish-user-service-preflight-contract-test.ts index 8444a4fc..456a96c5 100644 --- a/scripts/ci-publish-user-service-preflight-contract-test.ts +++ b/scripts/ci-publish-user-service-preflight-contract-test.ts @@ -108,6 +108,8 @@ async function main(): Promise { assertCondition(controlPlane.preferredRunnerPath === "frontend-private-proxy", "controlPlane should name frontend private proxy as preferred path", controlPlane); assertCondition(Array.isArray(record.missingChannels), "missingChannels should be an array", record); assertCondition(Array.isArray(record.missingControlChannels), "missingControlChannels should be an array", record); + assertCondition(Array.isArray(record.failedScopes), "failedScopes should be an array", record); + assertCondition((record.failedScopes as unknown[]).includes("local-docker-control-plane"), "failedScopes should expose publish-blocking registry scope", record); assertCondition(missingChannels.includes("backend-core-api"), "backend-core-api should be missing", record); assertCondition(missingChannels.includes("database"), "database should be missing", record); assertCondition(missingChannels.includes("provider-dispatch"), "provider-dispatch should be missing", record); diff --git a/scripts/src/remote.ts b/scripts/src/remote.ts index 15417f79..9e37bdfe 100644 --- a/scripts/src/remote.ts +++ b/scripts/src/remote.ts @@ -568,9 +568,9 @@ async function waitForFrontendTask(session: FrontendSession, taskId: string, tim const started = Date.now(); let latest: unknown = null; while (Date.now() - started < timeoutMs) { - latest = await frontendJson(session, "/api/tasks?limit=100"); - const tasks = (latest as { body?: { tasks?: Array<{ id?: string; status?: string; result?: unknown }> } }).body?.tasks ?? []; - const task = tasks.find((item) => item.id === taskId); + latest = await frontendJson(session, `/api/tasks/${encodeURIComponent(taskId)}`, undefined, 8000, 5_000_000); + const body = latest as { body?: { task?: { id?: string; status?: string; result?: unknown } } }; + const task = body.body?.task; if (task?.status === "succeeded" || task?.status === "failed") return { ok: true, task }; await Bun.sleep(500); } @@ -656,7 +656,7 @@ function commandResultFromFrontendTask(command: string[], task: { status?: strin stdout, stderr, signal: null, - timedOut: task?.status !== "succeeded" && stderr.includes("timeout"), + timedOut: result.timedOut === true || (task?.status !== "succeeded" && /timeout|timed out/iu.test(stderr)), }; } @@ -749,11 +749,15 @@ async function remoteCi(session: FrontendSession, config: UniDeskConfig, args: s }; }, commandCwd: ".", - artifactRegistryCommand: (probe) => ["frontend", "/api/dispatch", probe.providerId, "host.ssh", probe.action], + artifactRegistryCommand: (probe) => ["frontend", "/api/dispatch", probe.providerId, "host.ssh", probe.action, dispatchedTaskShape(probe.remoteCommandShape)], }), }; } +function dispatchedTaskShape(remoteCommandShape: string): string { + return remoteCommandShape.length > 0 ? remoteCommandShape : "host.ssh artifact-registry readonly probe"; +} + async function remoteCodeQueue(session: FrontendSession, args: string[]): Promise { const action = args[1] ?? "task"; if (action !== "task" && action !== "summary" && action !== "show" && action !== "tasks" && action !== "overview" && action !== "output" && action !== "judge") {