fix(runtime)!: preserve unknown debugger attachment state

Keep omitted discovery attachment state as null through Node, browser, Electron, and reconciliation evidence. Report the uncertainty while retaining Node observation unless discovery explicitly marks the target attached. Reject worker TargetInfo records missing the required boolean with partial coverage.

Validate omitted and explicit states through provider, CLI, and MCP boundaries and real Node 24 Inspector workflows. Consolidate Electron regression coverage into the existing list-and-inspect workflow.

BREAKING CHANGE: attached fields in JavaScript runtime, browser, and Electron target discovery and inspection results may be null when discovery does not report attachment state.
This commit is contained in:
morluto
2026-10-12 12:37:00 +08:00
parent 48c352b6bf
commit e55ef72135
23 changed files with 249 additions and 40 deletions
@@ -26,12 +26,19 @@ export const createInspectorExclusionCounts = (): Record<
});
/** Stable safety and protocol limitations shared by target-list Evidence. */
export const describeInspectorTargetLimitations = (): string[] => [
export const describeInspectorTargetLimitations = (
attachmentStateUnknown = false,
): string[] => [
"REA attaches to an already-running exact target and never launches, resumes, evaluates, pauses, or mutates it.",
"Only Runtime.enable and Debugger.enable are sent; source text, object values, EventEmitter activity, and Electron IPC are not inspected.",
"The selected endpoint and target ID authorize observation; discovery file locations can remain unresolved and do not prove filesystem identity.",
"Node discovery reports a best-effort pathname rather than an encoded file URL; lossy Windows paths and ambiguous underscores are preserved without guessing a file path.",
"Every target exposed by the selected Inspector endpoint is eligible for observation; target IDs and locations are not authenticated as operating-system process identity.",
...(attachmentStateUnknown
? [
"Inspector discovery did not report the target's current debugger attachment state; it is retained as unknown, and observation rejects only targets explicitly marked attached.",
]
: []),
"No runtime graph depth is traversed because passive Inspector events do not establish require/import caller edges.",
];
@@ -215,7 +222,7 @@ export const finalizeInspectorCapture = async ({
"A bounded observation window cannot establish that an unobserved script or behavior never occurs.",
"The declared Node/Electron process role is not authenticated by the Inspector protocol.",
],
limitations: describeInspectorTargetLimitations(),
limitations: describeInspectorTargetLimitations(target.attached === null),
};
};
+3 -3
View File
@@ -21,7 +21,7 @@ const targetSchema = z
id: z.string().min(1),
type: z.string().min(1),
url: z.string(),
attached: z.boolean().default(false),
attached: z.boolean().nullable().optional(),
webSocketDebuggerUrl: z.string().min(1),
})
.passthrough();
@@ -31,7 +31,7 @@ export interface V8InspectorTarget {
readonly id: string;
readonly type: string;
readonly url: string;
readonly attached: boolean;
readonly attached: boolean | null;
readonly webSocketUrl: string;
}
@@ -62,7 +62,7 @@ export const discoverV8Inspector = async (
id: target.id,
type: target.type,
url: target.url,
attached: target.attached,
attached: target.attached ?? null,
webSocketUrl: validatedInspectorWebSocket(
endpoint,
target.id,
+4 -2
View File
@@ -117,7 +117,9 @@ export class V8InspectorProvider implements JavaScriptRuntimeObservationPort {
runtime: discovery.runtime,
targets: allowed.map(projectTarget),
excluded: { ...excluded, unconnectable: 0 },
limitations: describeInspectorTargetLimitations(),
limitations: describeInspectorTargetLimitations(
allowed.some((target) => target.attached === null),
),
}),
);
} catch (cause: unknown) {
@@ -357,7 +359,7 @@ const authorizedTarget = async (
product,
});
if (
target.attached ||
target.attached === true ||
!decision.allowed ||
decision.location.kind === "builtin"
)