refactor: consolidate boundary semantics and prune redundant tests
Share parser modes and collision-free composite keys, enforce architecture guards, and consolidate redundant unit assertions into filesystem, CLI, MCP, and producer-backed workflows. Preserve concurrent upstream boundary fixes and exclude legacy Objective-C class-name bookkeeping labels. Validation: source/composition suites (3358 passing), focused canonical digest and MCP checks, typecheck/lint, Knip, formatting, architecture guards, and real Foundation archive and Apple legacy simulator CLI/MCP verification. No real Hopper, Ghidra, or IDA verification claim.
This commit is contained in:
@@ -6,6 +6,7 @@ import type {
|
||||
WebMcpDiscovery,
|
||||
} from "../domain/webMcpDiscovery.js";
|
||||
import { inferJsonShape } from "../domain/jsonShape.js";
|
||||
import { compositeKey } from "../domain/unicodeCodePointOrder.js";
|
||||
import type { CdpEndpointDiscovery, CdpEndpointTarget } from "./CdpEndpoint.js";
|
||||
import type { CdpConnection, CdpEvent } from "./CdpConnection.js";
|
||||
import { CdpCaptureCompleteness } from "./CdpCaptureCompleteness.js";
|
||||
@@ -502,8 +503,11 @@ const buildWebMcpResult = (options: WebMcpResultOptions): WebMcpDiscovery => {
|
||||
|
||||
const toolKey = (frameUrl: string, frameId: string, name: string): string =>
|
||||
// Registrations without a known admitted frame are excluded above, so the
|
||||
// frame ID here always distinguishes owners and keys cannot collapse.
|
||||
`webmcp_${createHash("sha256").update(`${frameUrl}\0${frameId}\0${name}`).digest("hex")}`;
|
||||
// frame ID here always distinguishes owners. Composite tuple keeps a NUL
|
||||
// inside one field from collapsing two registrations before hashing.
|
||||
`webmcp_${createHash("sha256")
|
||||
.update(compositeKey([frameUrl, frameId, name]))
|
||||
.digest("hex")}`;
|
||||
|
||||
const booleanOrNull = (value: unknown): boolean | null =>
|
||||
typeof value === "boolean" ? value : null;
|
||||
|
||||
@@ -268,6 +268,20 @@ const fetchOne = async (
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetch redirect statuses per WHATWG Fetch (redirect status list:
|
||||
* 301, 302, 303, 307, 308). Single owner for redirect decisions.
|
||||
* 300/304/305/306 carry `Location` without being redirects — following
|
||||
* them would replace the observed failure with an unrelated map.
|
||||
* See https://fetch.spec.whatwg.org/#redirect-status
|
||||
*/
|
||||
export const isFetchRedirectStatus = (status: number): boolean =>
|
||||
status === 301 ||
|
||||
status === 302 ||
|
||||
status === 303 ||
|
||||
status === 307 ||
|
||||
status === 308;
|
||||
|
||||
const fetchFollowingApprovedRedirects = async (
|
||||
initialUrl: string,
|
||||
allowedOrigins: readonly string[],
|
||||
@@ -298,9 +312,10 @@ const fetchFollowingApprovedRedirects = async (
|
||||
await response.body?.cancel(signal.reason).catch(() => undefined);
|
||||
throw signal.reason;
|
||||
}
|
||||
// Location is a redirect target only for the Fetch redirect statuses.
|
||||
// A 304 or another 3xx response must retain its own HTTP failure.
|
||||
if (![301, 302, 303, 307, 308].includes(response.status))
|
||||
// `Location` is a redirect target only for Fetch redirect statuses.
|
||||
// Other 3xx responses retain their own HTTP failure (strict identity:
|
||||
// never replace the observed failure with an unrelated map).
|
||||
if (!isFetchRedirectStatus(response.status))
|
||||
return { response, fetchedUrl: current };
|
||||
const location = response.headers.get("location");
|
||||
if (location === null) return { response, fetchedUrl: current };
|
||||
|
||||
Reference in New Issue
Block a user