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:
@@ -100,18 +100,24 @@ export class AnalysisOutputError extends AnalysisError {
|
||||
export class AnalysisCapabilityUnavailableError extends AnalysisError {
|
||||
readonly _tag = "AnalysisCapabilityUnavailableError";
|
||||
override readonly userMessage: string | undefined;
|
||||
/** Incomplete cleanup must settle before the operation can be retried. */
|
||||
readonly retryable: boolean;
|
||||
|
||||
constructor(
|
||||
readonly providerId: string,
|
||||
readonly operation: string,
|
||||
readonly reason: string,
|
||||
options?: AnalysisErrorOptions & { readonly userMessage?: string },
|
||||
options?: AnalysisErrorOptions & {
|
||||
readonly userMessage?: string;
|
||||
readonly retryable?: boolean;
|
||||
},
|
||||
) {
|
||||
super(
|
||||
`Provider ${providerId} cannot execute ${operation}: ${reason}`,
|
||||
options,
|
||||
);
|
||||
this.userMessage = options?.userMessage;
|
||||
this.retryable = options?.retryable === true && !this.cleanupIncomplete;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import {
|
||||
AnalysisAccessDeniedError,
|
||||
AnalysisArtifactChangedError,
|
||||
AnalysisCapabilityUnavailableError,
|
||||
AnalysisInputError,
|
||||
AnalysisUnsupportedTargetError,
|
||||
AnalysisResourceConstraintError,
|
||||
@@ -33,6 +34,8 @@ import type { AnalysisErrorProjection } from "./analysisErrorProjection.js";
|
||||
export const analysisErrorRemediationAction = (
|
||||
error: AnalysisError,
|
||||
): string => {
|
||||
if (error instanceof AnalysisCapabilityUnavailableError && error.retryable)
|
||||
return "Review details.reason, then retry the same analysis after the condition clears.";
|
||||
if (error instanceof EvidenceFileError && error.published !== undefined)
|
||||
return "Use the published file at details.published_path and resolve the reported staging cleanup failure.";
|
||||
if (error instanceof AnalysisSnapshotMismatchError)
|
||||
@@ -112,6 +115,8 @@ export const analysisErrorRemediationAction = (
|
||||
export const analysisErrorCategory = (
|
||||
error: AnalysisError,
|
||||
): AnalysisErrorProjection["category"] => {
|
||||
if (error instanceof AnalysisCapabilityUnavailableError && error.retryable)
|
||||
return "unavailable";
|
||||
if (
|
||||
error instanceof BinaryTargetError &&
|
||||
error.constraint === "load_selection_rejected"
|
||||
@@ -220,6 +225,8 @@ export const analysisErrorUserMessage = (error: AnalysisError): string => {
|
||||
const hopperMessage = hopperErrorUserMessage(error);
|
||||
if (hopperMessage !== undefined) return hopperMessage;
|
||||
if (error.userMessage !== undefined) return error.userMessage;
|
||||
if (error instanceof AnalysisCapabilityUnavailableError && error.retryable)
|
||||
return "Required runtime controls are unavailable for this attempt.";
|
||||
const standardMessage = standardErrorMessage(error._tag);
|
||||
if (standardMessage !== undefined) return standardMessage;
|
||||
if (error instanceof ArtifactOperationError) return artifactMessage(error);
|
||||
|
||||
@@ -25,6 +25,91 @@ import { ProviderSelectionError } from "./providerSelectionError.js";
|
||||
import { analysisErrorProjectionSchema } from "../contracts/errorSchemas.js";
|
||||
import { nativeCallPartialObservationSchema } from "./native/nativeCallPartialObservation.js";
|
||||
|
||||
describe("capability failure retry disposition", () => {
|
||||
it.each([
|
||||
{ options: {}, retryable: false, category: "unsupported_provider" },
|
||||
{
|
||||
options: { retryable: false },
|
||||
retryable: false,
|
||||
category: "unsupported_provider",
|
||||
},
|
||||
{ options: { retryable: true }, retryable: true, category: "unavailable" },
|
||||
] as const)(
|
||||
"preserves the producer's $retryable disposition",
|
||||
({ options, retryable, category }) => {
|
||||
const reason = "Native self-test failed with a sharing violation";
|
||||
const projected = projectAnalysisError(
|
||||
new AnalysisCapabilityUnavailableError(
|
||||
"fixture-provider",
|
||||
"inspect",
|
||||
reason,
|
||||
options,
|
||||
),
|
||||
);
|
||||
expect(projected).toMatchObject({
|
||||
code: "capability_unavailable",
|
||||
category,
|
||||
retryable,
|
||||
details: { reason },
|
||||
});
|
||||
if (retryable) {
|
||||
expect(projected.message).toBe(
|
||||
"Required runtime controls are unavailable for this attempt.",
|
||||
);
|
||||
expect(projected.remediation.action).toContain(
|
||||
"retry the same analysis",
|
||||
);
|
||||
}
|
||||
expect(analysisErrorProjectionSchema.safeParse(projected).success).toBe(
|
||||
true,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
it("preserves a caller-selected message for a retryable failure", () => {
|
||||
expect(
|
||||
projectAnalysisError(
|
||||
new AnalysisCapabilityUnavailableError(
|
||||
"fixture-provider",
|
||||
"inspect",
|
||||
"temporary failure",
|
||||
{
|
||||
retryable: true,
|
||||
userMessage: "Selected runtime diagnostic",
|
||||
},
|
||||
),
|
||||
).message,
|
||||
).toBe("Selected runtime diagnostic");
|
||||
});
|
||||
|
||||
it("retains cleanup ownership before allowing a transient operation to retry", () => {
|
||||
expect(
|
||||
projectAnalysisError(
|
||||
new AnalysisCapabilityUnavailableError(
|
||||
"fixture-provider",
|
||||
"inspect",
|
||||
"temporary failure",
|
||||
{
|
||||
retryable: true,
|
||||
cleanup: {
|
||||
reason: "owned handle is still live",
|
||||
resources: ["native-owner"],
|
||||
},
|
||||
},
|
||||
),
|
||||
),
|
||||
).toMatchObject({
|
||||
code: "cleanup_incomplete",
|
||||
retryable: false,
|
||||
details: {
|
||||
cleanup: "incomplete",
|
||||
resources: ["native-owner"],
|
||||
execution_failure: "capability_unavailable",
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("projects a published file receipt alongside retained cleanup failure", () => {
|
||||
const projected = projectAnalysisError(
|
||||
new EvidenceFileError("write", "io", {
|
||||
|
||||
@@ -83,6 +83,8 @@ export const projectAnalysisError = (
|
||||
message: analysisErrorUserMessage(error),
|
||||
retryable:
|
||||
RETRYABLE_CODES.has(code) ||
|
||||
(error instanceof AnalysisCapabilityUnavailableError &&
|
||||
error.retryable) ||
|
||||
(code === "resource_constraint" &&
|
||||
error instanceof AnalysisResourceConstraintError &&
|
||||
error.resource === "capacity"),
|
||||
|
||||
Reference in New Issue
Block a user