Skip to content

refactor(inspector): own the Node discovery path rule in one module - #10680

Merged
N0zoM1z0 merged 5 commits into
morluto:mainfrom
Davmunrey:refactor/node-discovery-owner
Nov 21, 2026
Merged

N0zoM1z0 merged 5 commits into
morluto:mainfrom
Davmunrey:refactor/node-discovery-owner

Conversation

@Davmunrey

Copy link
Copy Markdown
Contributor

Summary

Refs #9996. Two places decided whether Node Inspector discovery identifies a pathname exactly:

  • inline in authorizeRuntimeTargetLocation;
  • as NODE_DISCOVERY_AMBIGUOUS in the createNodeDiscoveryTempDirectory fixture (583bb47, f35b6a7).

This moves the rule into one module with no imports and uses it in both places. Behavior is unchanged.

Change and scope

  • New src/inspector/nodeDiscoveryPath.ts: isLosslessNodeDiscoveryPath(path, platform = process.platform). It returns true only for a non-Windows absolute path that contains no _, " or \.
  • JavaScriptRuntimeScope.ts uses it in place of the inline regex and platform check.
  • tests/fixtures/temporaryDirectory.ts uses it in place of its duplicated regex. The module imports nothing, so the shared fixture no longer has to load JavaScriptRuntimeScope and its Electron file-scope chain.
  • New nodeDiscoveryPath.test.ts covers the Windows branch, which Linux CI cannot reach through the boundary tests.

Evidence and regression coverage

  • src/inspector/nodeDiscoveryPath.test.ts and JavaScriptRuntimeScope.cancellation.test.ts: 12 passed.
  • javascriptRuntimeTargetLocations and javascriptRuntimeObservation with TMPDIR containing _: 42 passed. This exercises the /tmp fallback.
  • Gap: none beyond Windows, which the unit test covers by parameter.

Validation performed

  • npm run test:local -- src/inspector/nodeDiscoveryPath.test.ts src/inspector/JavaScriptRuntimeScope.cancellation.test.ts: 12 passed.
  • TMPDIR=…/bad_root npm run test:focused -- tests/boundary/inspector/javascriptRuntimeTargetLocations.test.ts tests/boundary/inspector/javascriptRuntimeObservation.test.ts: 42 passed.
  • npm run check:fast passed.

Author readiness

Human owner: @Davmunrey

  • 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

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

Node Inspector discovery reports a target as `file://` plus the pathname,
with quotes and backslashes replaced by underscores. Whether such a
pathname is identifiable was decided twice: inline in
authorizeRuntimeTargetLocation and again as NODE_DISCOVERY_AMBIGUOUS in
the createNodeDiscoveryTempDirectory fixture. The copies could drift, and
the fixture could not import the product rule without loading
JavaScriptRuntimeScope and its Electron file-scope chain.

Move the rule to src/inspector/nodeDiscoveryPath.ts, a module with no
imports, and use it from both places. Behavior is unchanged. A unit test
covers the Windows branch, which Linux CI cannot reach through the
boundary tests.

Validation: nodeDiscoveryPath and cancellation tests 12/12;
javascriptRuntimeTargetLocations and javascriptRuntimeObservation 42/42
with TMPDIR containing an underscore (exercises the /tmp fallback);
check:fast passes.

Refs morluto#9996
@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-14T23:22:58.209056Z
We couldn’t complete this review. Comment @codex review to try again.
cc56c83 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

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@greptile-apps

greptile-apps Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge; the shared rule preserves existing behavior.

Summary

This PR gives nodeDiscoveryPath.ts ownership of the Node discovery path rule.

  • Runtime checks and test fixtures use one Node discovery path rule.

No actionable issues were found. No previous review threads were supplied. The previous and current commits have different merge bases with the target, so this review covered the full PR. Tests were not rerun. Whether another PR supersedes this one could not be checked because GitHub access required authentication.

Reviews (6) · Last reviewed commit: "Merge morluto/rea main into node-discove..." · Reviewed by Greptile

Main now reports cancellation through cancelledBy and counts ambient
process.platform reads against a baseline that can only shrink. The
lossless-path rule takes the platform as a required parameter, so the
module still imports nothing and reads no host state. The one existing
process.platform read stays in JavaScriptRuntimeScope, where main
already counts it, and the fixture passes the platform itself.
Main now reads the host through HOST_PLATFORM in JavaScriptRuntimeScope and checks the same lossless-path rule inline (not Windows, absolute, no underscore, quote or backslash). The merge keeps that rule in isLosslessNodeDiscoveryPath, which already requires the absolute path, and passes HOST_PLATFORM.platform.

@gensokyo-dev gensokyo-dev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified: an equivalent refactor. The predicate matches the removed inline condition and the fixture's former regex, and the inspector scope tests and typecheck pass. Thanks.

@N0zoM1z0
N0zoM1z0 merged commit 559956c into morluto:main Nov 21, 2026
49 checks passed
@morluto morluto added the area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior label 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants