From 40e67cc17a7251d5aa3696867642de4f3c171f2f Mon Sep 17 00:00:00 2001 From: grayfoxey <63857797+grayfoxey@users.noreply.github.com> Date: Thu, 19 Nov 2026 20:55:10 +0900 Subject: [PATCH] fix(windows): recognize Japanese Task Scheduler states --- src/service/windows-checked-stop-live.ts | 10 +++++----- structure/ops/windows-checked-stop.md | 6 +++--- tests/windows/windows-checked-stop-live.test.ts | 16 ++++++++++++++++ 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/service/windows-checked-stop-live.ts b/src/service/windows-checked-stop-live.ts index e367e4ca808..9ffad578eaf 100644 --- a/src/service/windows-checked-stop-live.ts +++ b/src/service/windows-checked-stop-live.ts @@ -122,13 +122,13 @@ export const liveWindowsStopCommandRunner: WindowsStopCommandRunner = (program, /** * Status words of `schtasks /query /fo CSV /nh`. schtasks localizes the column from its .mui * resources, and the PowerShell fallback cannot start inside Part A's 1 s manager-state cap on a - * cold machine (#8863), so the words observed from shipped resources are read here: zh-CN from - * System32\zh-CN\schtasks.exe.mui, ko-KR from two machines. Any other word stays unknown and - * falls back to Get-ScheduledTask's locale-independent State enum. + * cold machine (#8863), so the words observed from shipped resources are read here: zh-CN and + * ja-JP from their System32 locale directories, ko-KR from two machines. Any other word stays + * unknown and falls back to Get-ScheduledTask's locale-independent State enum. */ // A queued instance can launch after Part A. Only ready and disabled prove inactivity. -const TASK_CSV_ACTIVE = new Set(["running", "queued", "正在运行", "已排队", "실행 중"]); -const TASK_CSV_NOT_RUNNING = new Set(["ready", "disabled", "就绪", "已禁用", "준비"]); +const TASK_CSV_ACTIVE = new Set(["running", "queued", "正在运行", "已排队", "실행 중", "実行中", "キューに登録済み"]); +const TASK_CSV_NOT_RUNNING = new Set(["ready", "disabled", "就绪", "已禁用", "준비", "準備完了", "無効"]); export function parseTaskCsvState(csv: string): "running" | "not-running" | "unknown" { for (const line of csv.split(/\r?\n/)) { diff --git a/structure/ops/windows-checked-stop.md b/structure/ops/windows-checked-stop.md index 1a947a8b594..e09a3208ed0 100644 --- a/structure/ops/windows-checked-stop.md +++ b/structure/ops/windows-checked-stop.md @@ -141,9 +141,9 @@ objects. The final manager-state probe treats both running and queued tasks as a [Task Scheduler permissions](https://learn.microsoft.com/en-us/windows/win32/taskschd/security-contexts-for-running-tasks) [Instance stop protocol](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-tsch/b3572584-8727-441f-83e6-9b02101ea7f4) -The task's running state is read from `schtasks /query /fo CSV`. The status words observed from shipped zh-CN and -ko-KR resources are recognized there (#8863), because a cold `Get-ScheduledTask` takes 1.6 s to -4.9 s and cannot finish inside the 1 s cap. Any other localized word still falls back to it. +The task's running state is read from `schtasks /query /fo CSV`. The status words observed from shipped +zh-CN, ko-KR, and ja-JP resources are recognized there, because a cold `Get-ScheduledTask` takes +1.6 s to 4.9 s (#8863) and cannot finish inside the 1 s cap. Any other localized word still falls back to it. The instance stop maps an access-denied HRESULT to `denied`. A running WinSW service is only this home's manager when `sc qc` shows a `BINARY_PATH_NAME` naming this installation's WinSW executable, the same proof the guarded manager path uses: the service ID is fixed, so a successful `sc query` alone diff --git a/tests/windows/windows-checked-stop-live.test.ts b/tests/windows/windows-checked-stop-live.test.ts index fd50849f3f5..de24c505b31 100644 --- a/tests/windows/windows-checked-stop-live.test.ts +++ b/tests/windows/windows-checked-stop-live.test.ts @@ -189,6 +189,22 @@ describe("capped command answers", () => { expect(programs).toEqual(["schtasks /query"]); }); + test.each([ + ["準備完了", "not-running"], + ["無効", "not-running"], + ["実行中", "running"], + ["キューに登録済み", "running"], + ])("ja-JP task state %s is read from the CSV without starting PowerShell", async (status, expected) => { + const deps = windowsCheckedStopLiveDeps({ + run: async (program, args) => { + expect(program).toBe("schtasks"); + expect(args).toEqual(["/query", "/tn", "opencodex-proxy", "/fo", "CSV", "/nh"]); + return result(0, `"\\opencodex-proxy","N/A","${status}"\r\n`); + }, + }); + expect(await deps.taskState(1_000)).toBe(expected); + }); + test("the helper must finish successfully and receive proof approval before reporting success", async () => { const sid = "S-1-5-21-100-200-300-1001"; const xml = buildWindowsTaskXml(undefined, windowsLauncherVbsPath(), undefined, sid)