fix(javascript): resolve module-relative Worker URL references (#2104)
* fix(javascript): resolve module-relative Worker URL references * fix(javascript): validate Worker URL paths independently of suffixes * fix(javascript): preserve directory-form Worker URL paths * fix(javascript): unwrap type assertions in Worker URL references * fix(javascript): validate Worker bindings before URL resolution * fix(javascript): leave drive-letter Worker URLs unresolved Use WHATWG file URL parsing before pathname decoding to detect drive-letter forms whose resource identity depends on the unmodeled source URL scheme. Preserve encoded and ordinary relative pipe paths, and cover false matches through the compiled CLI and resolver boundary tests. * fix(javascript): preserve Worker URL identity boundaries Recognize known Worker bindings before filtering callee spellings so ESM aliases and transparent constructor wrappers reach URL analysis. Keep root-relative module URLs unknown without a modeled runtime base root. Index direct source-local global writes with the shared mutation collector before promoting URL and browser Worker constructors. Preserve lexical shadowing and unrelated property identities, and exercise all three review regressions through the compiled CLI. * fix(javascript): invalidate mutated import.meta URL bases Track source-local import.meta writes alongside ambient global writes so Worker URL expressions keep an unknown base after a possible URL mutation. Tag the identity roots independently and cover direct mutation and unrelated property cases through the compiled CLI. * fix(javascript): close Worker URL identity and pathname gaps Resolve ambient object identities before appending written properties, and retain possible source-local aliases across rebinding. Reuse intrinsic invocation handling for aliased and bound mutators, array spreads, and transparent TypeScript wrappers while preserving Electron write semantics. Keep malformed-percent nested Worker URL pathnames unknown because the base scheme is unavailable and Node rejects these file URLs. Preserve tolerant HTML URL handling, valid escapes, and query/fragment evidence. Cover the new cases and unrelated writes through the compiled CLI with existing-file decoys. All 591 targeted tests and npm run check pass. * fix(javascript): bound alias expansion and classify Worker paths Join ambient identity projections instead of enumerating alias histories. Memoize repeated value and provenance queries while preserving capture, depth, and cycle-dependent uncertainty. Keep Node Worker string arguments unresolved without filesystem or cwd context, and admit qualified global URL constructors through identity checks. Validate three 40-level alias branch shapes through the compiled CLI, 925 source tests, 25 CLI/boundary tests, and the full npm run check gate. * fix(server): preserve partial Evidence target-content provenance Pass the exact named contract returnsTargetContent flag through the shared partial-Evidence error delivery path introduced by the shortlist integration. Exercise successful and failed recording through in-memory MCP for marked and unmarked contracts, preserving source payload and original failures. Observe both shared-handler emission and wire delivery so the SDK error-marker fallback cannot hide omissions. Suppressing the flag fails exactly the two marked cases. Validation: check:fast, check, 736 semantic tests, 29 MCP transport/error tests and six compiled static Worker CLI journeys pass. No live target/provider execution or hosted publication. * fix(javascript): structurally share semantic dependency proofs --------- Co-authored-by: baron <richstyles@gmail.com>
This commit is contained in:
1 parent
3b0ea590fc
commit
653067d799
19 files changed
+1946
-171
No files matched your search
@@ -1979,15 +1979,143 @@ describe("TypeScript NodeNext emitted-extension resolution", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("url-reference directory and empty-segment semantics", () => {
|
||||
it.each([
|
||||
"./worker.js/.",
|
||||
"./worker.js/child/..",
|
||||
"./worker.js/",
|
||||
"/dist/worker.js/.",
|
||||
"./worker.js/.?cache=1#entry",
|
||||
])("keeps directory-form URLs distinct from files: %s", (declaredPath) => {
|
||||
expect(
|
||||
resolve({
|
||||
declaredPath,
|
||||
sourcePath: "dist/app.mjs",
|
||||
context: "url-reference",
|
||||
files: fileMap([file("dist/worker.js", "root")]),
|
||||
}),
|
||||
).toMatchObject({
|
||||
declared_path: declaredPath,
|
||||
resolution_status: "not-found",
|
||||
resolved_path: null,
|
||||
});
|
||||
});
|
||||
|
||||
it.each(["./nested//worker.js", "./nested//../worker.js"])(
|
||||
"does not collapse empty URL path segments: %s",
|
||||
(declaredPath) => {
|
||||
expect(
|
||||
resolve({
|
||||
declaredPath,
|
||||
sourcePath: "dist/app.mjs",
|
||||
context: "url-reference",
|
||||
files: fileMap([
|
||||
file("dist/worker.js", "root"),
|
||||
file("dist/nested/worker.js", "root"),
|
||||
]),
|
||||
}),
|
||||
).toMatchObject({ resolved_path: null });
|
||||
},
|
||||
);
|
||||
|
||||
it.each([
|
||||
["./nested/.././worker.js?cache=1#entry", "dist/worker.js"],
|
||||
["./.worker.js", "dist/.worker.js"],
|
||||
])("resolves exact file URLs with dots: %s", (declaredPath, resolvedPath) => {
|
||||
expect(
|
||||
resolve({
|
||||
declaredPath,
|
||||
sourcePath: "dist/app.mjs",
|
||||
context: "url-reference",
|
||||
files: fileMap([file(resolvedPath, "root")]),
|
||||
}),
|
||||
).toMatchObject({
|
||||
resolution_status: "resolved",
|
||||
resolved_path: resolvedPath,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("url-reference JavaScript artifact path resolution", () => {
|
||||
it.each([
|
||||
["C|?cache=1#entry", "dist/C|"],
|
||||
["/c:/worker.js", "c:/worker.js"],
|
||||
["/./c|/worker.js", "c|/worker.js"],
|
||||
["../c|/worker.js", "c|/worker.js"],
|
||||
["/nested/../c|/worker.js", "c|/worker.js"],
|
||||
["c|/../worker.js", "dist/worker.js"],
|
||||
])("leaves drive-letter URL paths unresolved: %s", (declaredPath, decoy) => {
|
||||
const resolution = resolve({
|
||||
declaredPath,
|
||||
sourcePath: "dist/app.mjs",
|
||||
context: "url-reference",
|
||||
files: fileMap([file(decoy, "root")]),
|
||||
});
|
||||
expect(resolution).toMatchObject({
|
||||
declared_path: declaredPath,
|
||||
resolution_status: "unavailable",
|
||||
resolved_path: null,
|
||||
});
|
||||
expect(resolution.limitations.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it.each([
|
||||
["./c|/worker.js", "dist/c|/worker.js"],
|
||||
["c|name/worker.js", "dist/c|name/worker.js"],
|
||||
["/%63|/worker.js", "c|/worker.js"],
|
||||
["/c%3A/worker.js", "c:/worker.js"],
|
||||
])(
|
||||
"retains non-drive URL path identities: %s",
|
||||
(declaredPath, resolvedPath) => {
|
||||
expect(
|
||||
resolve({
|
||||
declaredPath,
|
||||
sourcePath: "dist/app.mjs",
|
||||
context: "url-reference",
|
||||
files: fileMap([file(resolvedPath, "root")]),
|
||||
}),
|
||||
).toMatchObject({
|
||||
declared_path: declaredPath,
|
||||
resolution_status: "resolved",
|
||||
resolved_path: resolvedPath,
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
it.each(["?value=", "#value="])(
|
||||
"admits the pathname independently of its %s suffix",
|
||||
(suffix) => {
|
||||
for (const value of ["%2F", "%2E", "%5C", "%00", "%FF", "\\", "\0"]) {
|
||||
const declaredPath = `./worker.js${suffix}${value}`;
|
||||
expect(
|
||||
resolve({
|
||||
declaredPath,
|
||||
sourcePath: "dist/app.js",
|
||||
context: "url-reference",
|
||||
files: fileMap([file("dist/worker.js", "root")]),
|
||||
}),
|
||||
declaredPath,
|
||||
).toMatchObject({
|
||||
declared_path: declaredPath,
|
||||
resolution_status: "resolved",
|
||||
resolved_path: "dist/worker.js",
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
it.each([
|
||||
"app\0.js.map?valid=1",
|
||||
"nested\\worker.js#valid",
|
||||
"app%00.js.map",
|
||||
"app%FF.js.map",
|
||||
"app%C0%AF.js.map",
|
||||
"app%2ejs.map",
|
||||
"nested%2fworker.js",
|
||||
"nested%5cworker.js",
|
||||
"h\nttp://[",
|
||||
"../../outside.js.map",
|
||||
"../../outside/.",
|
||||
])("rejects an inadmissible URL path: %s", (declaredPath) => {
|
||||
const resolution = resolve({
|
||||
declaredPath,
|
||||
|
||||
Reference in new issue
Block a user