From 044f180222d9b20ef1c23a0a5e4dac32002cd696 Mon Sep 17 00:00:00 2001 From: morluto <76467478+morluto@users.noreply.github.com> Date: Wed, 21 Oct 2026 12:37:26 +0800 Subject: [PATCH] test(cli): accept opaque Kuna doctor run tokens (#5677) * test(cli): accept opaque Kuna doctor run tokens The doctor cancellation fixture parsed REA_PROCESS_RUN_ID as a UUID. Kuna version probes publish rea-kuna-version-, so both signal cases failed before checking cancellation. Accept that opaque token and keep the JADX ownership check on a UUID. Co-authored-by: morluto * test(cli): require the Kuna doctor run token An omitted REA_PROCESS_RUN_ID disappears from the ready JSON. The Kuna cancellation case now rejects that record unless runId is a non-empty ownership token. JADX still requires a UUID. Co-authored-by: morluto --------- Co-authored-by: Cursor Agent Co-authored-by: morluto --- tests/boundary/cli/doctorCancellation.test.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/tests/boundary/cli/doctorCancellation.test.ts b/tests/boundary/cli/doctorCancellation.test.ts index 530427dcc6..7ebcfeae86 100644 --- a/tests/boundary/cli/doctorCancellation.test.ts +++ b/tests/boundary/cli/doctorCancellation.test.ts @@ -40,13 +40,11 @@ cliTest.skipIf(!["darwin", "linux"].includes(process.platform)).for( const executable = provider === "kuna" ? join(root, "kuna") : join(jdk, "bin", "java"); const probeArgument = provider === "kuna" ? "--version" : "--list-modules"; - const runIdField = - provider === "jadx" ? ",runId:process.env.REA_PROCESS_RUN_ID" : ""; await writeFile( executable, `#!${process.execPath} if (!process.argv.slice(2).includes(${JSON.stringify(probeArgument)})) process.exit(7); -require("node:fs").writeFileSync(${JSON.stringify(ready)}, JSON.stringify({pid: process.pid${runIdField}})); +require("node:fs").writeFileSync(${JSON.stringify(ready)}, JSON.stringify({pid: process.pid, runId: process.env.REA_PROCESS_RUN_ID})); process.on("SIGTERM", () => {}); setInterval(() => { if (require("node:fs").existsSync(${JSON.stringify(release)})) process.exit(0); }, 25).unref(); setTimeout(() => process.exit(99), 20000); @@ -97,7 +95,10 @@ setTimeout(() => process.exit(99), 20000); ) .toBe(true); const readyRecord: unknown = JSON.parse(await readFile(ready, "utf8")); - const observed: { readonly pid: number; readonly runId?: string } = + // JADX publishes a UUID. Kuna publishes an opaque + // `rea-kuna-version-` token. Both are required: JSON.stringify + // drops an undefined REA_PROCESS_RUN_ID, and that omission must fail. + const observed = provider === "jadx" ? z .strictObject({ @@ -106,11 +107,12 @@ setTimeout(() => process.exit(99), 20000); }) .parse(readyRecord) : z - .strictObject({ pid: z.number().int().positive() }) + .strictObject({ + pid: z.number().int().positive(), + runId: z.string().min(1), + }) .parse(readyRecord); if (provider === "jadx") { - if (observed.runId === undefined) - throw new Error("Missing JADX run token"); ownership = { leaderPid: observed.pid, processGroupId: observed.pid, @@ -131,8 +133,7 @@ setTimeout(() => process.exit(99), 20000); state: "empty", }); } else { - // Kuna's version probe uses a joined direct execFile child, without a - // detached run-token group. Do not invent a group owner from its PID. + // Do not invent a group owner from the probe PID. expect(() => process.kill(observed.pid, 0)).toThrowError( expect.objectContaining({ code: "ESRCH" }), );