fix(windows): preserve transient runtime admission failures (#2467)

Fixes #2257. Thanks to @chqcjq for the native self-test retry diagnosis in #2266.

Preserve retry disposition through analysis workflows. Native warm admission requires exact sharing/lock codes and affirmative pre-allocation evidence; cleanup ownership takes precedence. No automatic retry or new analysis cache.

Verified with real Windows 11 CLI, same-connection SDK MCP normal/conflict/recovery, the Windows native verifier, 99 focused tests and static/docs gates. Official npm 11.16.0 launcher sources were the application input. No IDA or Ghidra engine was used for this change. Win32 5 was not reproduced; no resolution claim for #1701/#2196. Performance measurements and limits are recorded in experiments/analysis-efficiency/windows-runtime-retry.md.
This commit is contained in:
Ysopwnable
2026-10-13 11:42:54 +08:00
committed by GitHub
parent 23de4f77c7
commit 172407787f
20 changed files with 491 additions and 62 deletions
+33
View File
@@ -11,6 +11,7 @@ import {
mkdtemp,
readFile,
rename,
readdir,
rm,
symlink,
writeFile,
@@ -37,6 +38,14 @@ const { WindowsPrivateRuntime, windowsPrivateRuntime } = await import(
const { ghidraSessionRoot } = await import(
pathToFileURL(join(packageRoot, "dist/ghidra/GhidraSessionRoot.js"))
);
const { PrivateRuntimeRoot } = await import(
pathToFileURL(join(packageRoot, "dist/process/PrivateRuntimeRoot.js"))
);
const { PrivateRuntimeRootUnavailableError } = await import(
pathToFileURL(
join(packageRoot, "dist/process/PrivateRuntimeRootUnavailableError.js"),
)
);
const workspace = await mkdtemp(join(tmpdir(), "rea-native-conformance-"));
const environment = Object.entries(process.env)
.filter(([, value]) => value !== undefined)
@@ -140,6 +149,30 @@ process.stdout.write(JSON.stringify({executable:basename(process.execPath),abiVe
])
assert.throws(() => native.call("open", [rejected]));
report.controls.ordinaryDriveSeparatorsAndRequestedIdentity = true;
// An owned runtime's DELETE lease conflicts with a fresh parent admission.
// This produces a genuine sharing failure after successful authority caching,
// without another executable, and proves that no child runtime was created.
const sharingParent = WindowsPrivateRuntime.create(
workspace,
"rea-sharing-parent-",
);
try {
await assert.rejects(
PrivateRuntimeRoot.create({ parent: sharingParent.observation.path }),
(failure) => {
assert.ok(failure instanceof PrivateRuntimeRootUnavailableError);
assert.equal(failure.retryable, true);
assert.ok(failure.cause instanceof Error);
assert.equal(failure.cause.win32Code, 32);
assert.equal(failure.cause.runtimeAllocation, "not-started");
return true;
},
);
assert.deepEqual(await readdir(sharingParent.observation.path), []);
report.controls.transientRuntimeAdmissionBeforeAllocation = true;
} finally {
await sharingParent.close();
}
const driveRoot = parse(workspace).root;
const runtimeParent = ghidraSessionRoot({
base: join(driveRoot, ".Tmp", "scratch"),