Skip to content

fix(javascript): preserve trailing-slash exports uncertainty - #10107

Closed
dimxxkun wants to merge 1 commit into
morluto:mainfrom
dimxxkun:fix/trailing-slash-package-exports
Closed

dimxxkun wants to merge 1 commit into
morluto:mainfrom
dimxxkun:fix/trailing-slash-package-exports

Conversation

@dimxxkun

Copy link
Copy Markdown
Contributor

Summary

Fixes #9998. Preserve an uncertain resolution result for package exports wildcard requests ending in /, instead of incorrectly classifying them as external.

Related work: #2018 implements broader exports/imports wildcard resolution and overlaps this code. This PR is a narrow correction to the current conservative behavior; maintainers may prefer to incorporate it there.

Problem and expected behavior

For exports: { "./*": "./lib/*.js" }, Node can resolve dep/a/ to lib/a/.js. REA currently returns external before checking wildcard keys. Since full wildcard expansion is unsupported here, the correct existing-contract outcome is unavailable, with no invented resolved path. Exact keys ending in / must still be ignored, while a matching null wildcard remains blocked.

Change and scope

Move the trailing-slash guard into exact-key selection so wildcard matching can still run. Add import/require regression cases and a CLI/stdio MCP acceptance test with a native Node resolution oracle. Full wildcard expansion is outside this change.

Contract and boundary impact

  • Semantic owner: selectPackageExport in JavaScriptArtifactPathResolution.ts; package-export selection feeds JavaScript graph edge resolution. Existing pattern selection and target evaluation remain shared.
  • Contribution scope: ordinary fix within existing static-analysis boundaries; new-capability maintainer decision not applicable.
  • CLI/MCP: no schema or tool-catalog changes. Affected edges report resolution_status: unavailable and resolved_path: null instead of external.
  • Compatibility: applies to import and require package-export selection. Exact exports and null wildcard exclusions retain their behavior.
  • Evidence/provenance: existing source evidence is retained; the acceptance test checks both consumer source locations. Uncertainty remains explicit.
  • Authority/cleanup: production analysis still reads selected files without executing target modules. Tests create temporary fixtures using the existing cleanup helper and run Node resolution APIs; selected modules throw if executed.
  • Metadata/package/install impact: none; no dependencies, generated files, or installation behavior changed.

Expected production effects: read existing files. No additional target execution, mutation, network access, or protection recovery is introduced.

Evidence and regression coverage

  • On base 48357cb34, the source regression suite had 2 failures and 310 passes: trailing-slash wildcard cases returned external where unavailable was expected. With the fix, all 312 pass.
  • Source cases cover wildcard matches, exact trailing-slash null keys, exact-only trailing-slash keys, and null wildcard exclusions, for import and require.
  • The new acceptance test covers CLI and stdio MCP, ordinary/trailing-slash wildcard requests, exact exports, blocked wildcards, and source provenance. Native import.meta.resolve and require.resolve oracle assertions passed without loading target modules.
  • Remaining proof gap: both real REA endpoint cases fail before resolution, during source transfer, with Unknown native filesystem operation (Win32 87): The parameter is incorrect. This occurs on both the base and fixed code in this Windows environment. Endpoint success and final graph assertions are therefore not claimed.
  • Boundary coverage: preserves unsupported/uncertain versus absent/blocked outcomes. No resource lifecycle behavior changes.

Validation performed

Environment: Windows x64, Node 24.22.1, npm 11.16.0.

  • npm run test:local -- src/application/javascript/JavaScriptArtifactPathResolution.test.ts src/domain/javascript/javascriptPackageSubpathPatterns.test.ts src/domain/javascript/javascriptPackageImportAliases.test.ts — 360 passed across 3 files.
  • npm run test:focused -- tests/acceptance/applications/javascriptTrailingSlashExports.test.ts — 2 failed on both base and fix at the pre-resolution Windows source-transfer boundary described above; Node oracle assertions passed.
  • npm run verify:test-discovery — 3434 test files discovered exactly once.
  • git diff --check — passed.
  • npm run check — typecheck, lint, formatting, metadata checks, and runtime compilation passed. The gate stopped at Knip on the pre-existing unused exported type AdbDeviceState in src/domain/adb/adbDeviceAnalysis.ts:54; subsequent chained checks did not run.

Compatibility, safety, and release

No schema migration, dependency, release metadata, target execution, or containment change. Windows endpoint verification remains incomplete as recorded above; Linux/macOS were not exercised locally. Hopper/Ghidra coverage is not applicable to this JavaScript-only change.

Author readiness

Human owner: @dimxxkun

This is a draft. The declarations below are reserved for the human owner and have not been made by the assistant.

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

@N0zoM1z0

Copy link
Copy Markdown
Collaborator

Thank you for this fix. It landed in #10538 with your authorship kept on the commit (plus review follow-ups noted in the PR), so I'm closing this PR as superseded.

@N0zoM1z0 N0zoM1z0 closed this Nov 14, 2026
@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] analyze-javascript-application reports no export for a matching trailing-slash wildcard subpath

3 participants