Skip to content

fix(javascript): route directories by JavaScript input presence and name directory-capable operations - #14186

Merged
morluto merged 2 commits into
mainfrom
fix/directory-input-routing-14161
Nov 23, 2026
Merged

morluto merged 2 commits into
mainfrom
fix/directory-input-routing-14161

Conversation

@morluto

@morluto morluto commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Part of #14161

Owner decision

An empty directory is "nothing to analyze", not "unsupported", so it keeps returning Evidence. A non-empty directory with no JavaScript inputs no longer gets a silent all-zero summary. It gets a typed refusal that includes bounded routing facts: counts by format, with no file lists.

Behaviour matrix (analyze <dir> / analyze_javascript_application)

Inventory Presence Outcome
Complete traversal, JavaScript / HTML / package.json / source map / nested ASAR present present Analysis as before.
Complete traversal, no non-directory entries empty Evidence as before (complete coverage, zero inputs). It now also has the limitation "No JavaScript inputs were found: the complete inventory contains no files…", which names the next operations.
Complete traversal, entries but none of the above (for example PE images, JSON, CMake files) absent unsupported_target refusal. details.diagnostics has {inventoried_entries, entries_by_format, json_files, native_addon_files}, e.g. {"inventoried_entries":4,"entries_by_format":{"file":2,"pe":2},"json_files":1,"native_addon_files":0}. related_operations lists inspect_desktop_application, audit_release_exposure, inspect_artifact and open_binary.
Incomplete traversal, or an unavailable relevant file of unknown kind unknown Analysis as before, with the existing coverage limitations. Unknown is not treated as absent.

The JS result schema has no next-probes field, so the empty case names its next probes in the limitation text. No contract or schema changed.

Root cause

  • analyze sends every directory that is not an Apple bundle to the JavaScript lane. The lane never classified whether its own inventory held anything it analyzes, so native build output came back as an exit-0, all-zero Electron summary.
  • The directory_requires_file presentation hard-coded open_binary as the refusing operation and listed only analyze_javascript_application as an alternative. inspect and inspect-artifact inherited that advice.

Structural fix

  • javaScriptApplicationInputPresence and javaScriptAbsentInputDiagnostics (src/domain/javascript/javascriptArtifactFiles.ts) classify presence once. They use facts the lane already holds: the relevant-kind file set from readJavaScriptArtifactFiles and the inventory occurrences/coverage. The root occurrence is excluded and nothing is re-scanned.
  • reconstructJavaScriptArtifact refuses absent targets.
  • The graph builder's graphLimitations, which owns the result's limitations, adds the empty-input limitation for empty targets.
  • The directory_requires_file message is now operation-neutral. Its remediation and related_operations name inspect_desktop_application, audit_release_exposure and analyze_javascript_application.

The inspect-desktop-application part of the issue (≈30k tokens, no candidates or probes for native PE headers) has a different root cause in the desktop projection. It overlaps #14173 and #14179 and is not fixed here, so this PR is "Part of".

Tests

  • tests/boundary/filesystem/javascriptApplicationInputSelection.test.ts covers:
    • The refusal and its exact diagnostics for 2 PE images (from the pe() fixture) + JSON + a CMake directory, with no paths leaked.
    • An empty directory (with an empty subdirectory) analyzed with the no-input limitation.
    • Controls for HTML-only, package.json-only and source-map-only directories.
  • tests/boundary/cli/analyzeAppBundlePathCli.test.ts covers public rea analyze <dir>: the native-directory refusal with diagnostics, the empty-directory limitation, and an HTML-only control.
  • Updated directory_requires_file expectations in targetDiagnostics.test.ts and rawBinaryCli.test.ts.
  • The earlier fixture edits that added package.json to empty directories are reverted. Those four tests pass unchanged against main's fixtures.

Validation run

  • npx oxfmt / npx oxlint on the changed files: formatted. The changed files raise no new lint warnings; existing size/complexity warnings remain.
  • node scripts/verify/architecture-guards.mjs: passed across 3075 source files.
  • npx vitest run tests/boundary/filesystem/javascriptApplicationInputSelection.test.ts: 11 passed, 2 failed. The 2 failures are the existing access-denied tests. They analyze a .js file and need the built worker dist/composition/javascriptAnalysisWorkerProcess.js, which was absent because I did not build.
  • Targeted run of targetDiagnostics, appleBundleTargets, and the reverted empty-directory fixtures in javascriptApplicationWorkflows / sourceToBundlePaths: all pass except tests that need the built JS worker. Those fail with ProviderAdapterError before any applicability decision.
  • Source-only run of the 54 JS-lane boundary files: the absent refusal text appears in none of the failures. Every failure there comes from the missing built worker.
  • Not run locally: the built CLI tests (analyzeAppBundlePathCli.test.ts, rawBinaryCli.test.ts), the full typecheck and MCP. CI has to cover them. No real-provider verification applies.

Remaining cleanup

…e directory-capable operations

`analyze <dir>` routed every non-bundle directory to the static JavaScript
lane, which reported an all-zero Electron summary as success for native
build output. The JavaScript lane now owns that applicability decision from
its complete inventory: when coverage is complete and no JavaScript, HTML,
package.json, source map, or nested ASAR input exists, it returns a typed
unsupported_target refusal naming inspect_desktop_application,
audit_release_exposure, inspect_artifact, and open_binary. Incomplete
coverage or unavailable files of unknown kind stay unknown and proceed.

The directory_requires_file refusal no longer claims to come from
open_binary when another operation (inspect, inspect-artifact) admitted the
target, and it names the directory-capable operations instead of only the
JavaScript lane.
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-23T21:58:19.747282Z
We couldn’t complete this review. Comment @codex review to try again.
52f3699 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@greptile-apps

greptile-apps Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The reviewed changes appear safe to merge.

Summary

The PR refuses nonempty targets that have no JavaScript application inputs and gives callers other operations to use.

  • JavaScript analysis refuses nonempty folders with no app inputs.
  • Directory-opening errors now name operations that accept folders.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Read inventory and file facts] --> B{Application inputs found?}
  B -->|Yes| C[Analyze]
  B -->|No| D{Coverage complete and kinds known?}
  D -->|No| C
  D -->|Yes| E{Contained non-directory entries?}
  E -->|Yes| F[Refuse with format counts and next operations]
  E -->|No| G[Analyze with no-input warning]
Loading

Reviews (2) · Last reviewed commit: "fix(javascript): keep empty directories ..." · Reviewed by Greptile

… facts for non-JavaScript ones

Owner decision on #14186: an empty directory is "nothing to analyze", not
"unsupported". The JavaScript lane now classifies application-input
presence once, in the domain owner of its file facts
(javaScriptApplicationInputPresence): present, empty, absent, or unknown.

- empty (complete traversal, no non-directory entries): analysis succeeds
  as before and the graph carries an explicit "No JavaScript inputs were
  found" limitation naming the next operations.
- absent (complete traversal, entries but no JavaScript, HTML,
  package.json, source map, or nested ASAR): the typed unsupported_target
  refusal now carries bounded diagnostics from the inventory the lane
  already read: inventoried_entries, entries_by_format, json_files and
  native_addon_files. No paths are retained.
- unknown (incomplete traversal or unavailable file of unknown kind) and
  present: unchanged analysis.

Reverts the fixture edits that added package.json to empty directories.
morluto added a commit that referenced this pull request Nov 23, 2026
… facts for non-JavaScript ones

Owner decision on #14186: an empty directory is "nothing to analyze", not
"unsupported". The JavaScript lane now classifies application-input
presence once, in the domain owner of its file facts
(javaScriptApplicationInputPresence): present, empty, absent, or unknown.

- empty (complete traversal, no non-directory entries): analysis succeeds
  as before and the graph carries an explicit "No JavaScript inputs were
  found" limitation naming the next operations.
- absent (complete traversal, entries but no JavaScript, HTML,
  package.json, source map, or nested ASAR): the typed unsupported_target
  refusal now carries bounded diagnostics from the inventory the lane
  already read: inventoried_entries, entries_by_format, json_files and
  native_addon_files. No paths are retained.
- unknown (incomplete traversal or unavailable file of unknown kind) and
  present: unchanged analysis.

Reverts the fixture edits that added package.json to empty directories.

Claude-Session: https://claude.ai/code/session_01TBh3FSTJTdVSc2DntiwVY7
@morluto morluto changed the title fix(javascript): refuse directories without JavaScript inputs and name directory-capable operations fix(javascript): route directories by JavaScript input presence and name directory-capable operations Nov 23, 2026
@morluto
morluto force-pushed the fix/directory-input-routing-14161 branch from 4a3a9dc to 9e48702 Compare November 23, 2026 22:50
@morluto
morluto merged commit 6dadd30 into main Nov 23, 2026
47 checks passed
@morluto
morluto deleted the fix/directory-input-routing-14161 branch November 23, 2026 23:00
@morluto morluto added area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior bug Something isn't working labels Nov 26, 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.

1 participant