Skip to content

test(inspector): keep Node discovery fixtures out of underscored temp dirs - #4484

Closed
Kenmege wants to merge 2 commits into
morluto:mainfrom
Kenmege:fix/macos-node-discovery-tmpdir
Closed

Kenmege wants to merge 2 commits into
morluto:mainfrom
Kenmege:fix/macos-node-discovery-tmpdir

Conversation

@Kenmege

@Kenmege Kenmege commented Oct 16, 2026 •

Copy link
Copy Markdown

Summary

Four inspector boundary tests cannot pass on macOS hosts whose per-user temporary directory contains an underscore. Their fixtures are created under realpath(os.tmpdir()), and REA deliberately treats a Node-reported path containing _ as unverifiable. This keeps those fixtures in a temporary directory whose canonical path cannot be confused with Node's lossy rewriting. Test-only change; no product behaviour changes.

Problem and expected behavior

authorizeRuntimeTargetLocation (src/inspector/JavaScriptRuntimeScope.ts) marks a Node-reported POSIX file:// path containing _, " or \ as unverifiable-file-location, because Node's Inspector discovery metadata replaces quotes and backslashes with underscores. That rule is correct and unchanged.

On macOS, os.tmpdir() is a per-user directory of the shape /private/var/folders/<x>/<y>/T, and <y> often contains _. Every fixture that createTestTempDirectory creates there is therefore reported as unresolved. These tests expect a verified file location, so they fail on such hosts:

  • javascriptRuntimeObservation.test.ts: "includes targets outside the old caller root filter"
  • javascriptRuntimeTargetLocations.test.ts: "interprets entry#hash.js / entry%percent.js / entry%23hash.js as a literal Node discovery path on POSIX"

Linux /tmp contains none of those characters, so the tests pass there.

Change and scope

tests/fixtures/temporaryDirectory.ts gains createNodeDiscoveryTempDirectory(prefix):

  • On POSIX it uses the canonical temporary directory when it is free of _, " and \. Only otherwise does it resolve the canonical /tmp, so a host without /tmp still works when tmpdir() is clean.
  • It fails loudly when neither is clean, rather than silently producing an ambiguous fixture.
  • Windows keeps createTestTempDirectory, since Node discovery paths are never verified there.
  • Cleanup is the same onTestFinished → removeTestWorkspace path.

The two inspector test files use it for their fixture roots. No assertion changes.

Contribution scope: an ordinary test fix within existing boundaries; a maintainer scope decision is not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: test fixtures only.
  • Contribution scope fit and linked maintainer decision: not applicable (test-only fix).
  • CLI and MCP/tool-catalog contract: none.
  • Provider, bridge, target-format, or platform compatibility: none in product code. Test fixtures on macOS may now live under /private/tmp.
  • Evidence, artifact, provenance, or reconstruction contract: none.
  • Target selection, authority, upstream behavior, and cleanup details: unchanged; fixture cleanup uses the existing helper.
  • Generated metadata, package, or installation impact: none.

Evidence and regression coverage

  • Tests added or updated: the two inspector test files now build their fixture roots with the new helper.
  • Base reproduction (macOS 27 arm64 host whose TMPDIR contains _, Node 24.18.0 from .nvmrc): npx vitest run tests/boundary/inspector/javascriptRuntimeObservation.test.ts tests/boundary/inspector/javascriptRuntimeTargetLocations.test.ts at fe2a398 fails 4 of 38 tests, the 4 named above. Each receives { kind: "unresolved", reason: "unverifiable-file-location" }.
  • With this change, on the same host: 38/38 pass.
  • Remaining proof gaps: not run on Linux or Windows locally. On Linux the helper resolves to realpath(os.tmpdir()) exactly as before, unless TMPDIR itself contains _, " or \. On Windows it is the old helper. CI covers both.

Validation performed

  • npx vitest run on the two files at fe2a398: 4 failed / 34 passed (38).
  • The same at this branch: 38 passed with the default (underscored) TMPDIR, and 38 passed with a clean TMPDIR (primary used).
  • npm run check:fast: passed (2/2 tasks).
  • npm run check: passed (6/6 tasks; architecture guards passed across 1455 source files).
  • npm run verify:test-discovery: discovered all 1417 test files exactly once.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: macOS host only, as above.
  • Package or release metadata impact: none (tests only).
  • Security, privacy, process, or containment review: not applicable; no product code changes.

Author readiness

Human owner: @Kenmege (the declarations below are left for the human owner, per the template)

  • 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.

Kenmege and others added 2 commits October 16, 2026 14:09
… dirs

authorizeRuntimeTargetLocation treats a Node-reported POSIX path containing
'_', '"' or '\' as unverifiable, because Node's Inspector discovery metadata
replaces quotes and backslashes with underscores. The javascriptRuntimeObservation
and javascriptRuntimeTargetLocations fixtures were created under
realpath(os.tmpdir()). On macOS that is a per-user directory of the shape
/private/var/folders/<x>/<y>/T, where <y> often contains '_', so four tests could
never verify their own fixture there; Linux's /tmp has no such characters.

createNodeDiscoveryTempDirectory uses the canonical temporary directory when it
is free of those characters, otherwise the canonical /tmp, and fails when
neither is. Windows keeps createTestTempDirectory. No assertion changes; the
product rule that such paths are unverifiable is unchanged and still tested.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolving realpath("/tmp") unconditionally rejects on a POSIX host without
/tmp even when tmpdir() is clean, failing both inspector test files before
they create a fixture. Resolve the primary first and fall back to /tmp only
when it contains '_', '"' or '\'.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@morluto

morluto commented Oct 26, 2026

Copy link
Copy Markdown
Owner

Thanks for identifying the macOS temporary-path interaction. The Inspector path owner still treats ambiguous discovery spellings as unresolved, so this test-fixture issue remains distinct. GitHub reports a conflict; could you refresh the fixture change against main and preserve both safe temporary-directory ownership and the explicit ambiguous-path coverage? Please distinguish any real macOS run from simulated or source-only checks.

gensokyo-dev added a commit that referenced this pull request Nov 14, 2026
…rscored roots

Use createNodeDiscoveryTempDirectory for the target-location and
runtime-observation fixtures too, so a TMPDIR containing `_` cannot make
them fail for the same reason as the cancellation test.

Refs #9996

The sibling sites are the ones #4484 switched.

Co-Authored-By: gensokyo-dev <[email protected]>
N0zoM1z0 pushed a commit that referenced this pull request Nov 14, 2026
…rscored roots

Use createNodeDiscoveryTempDirectory for the target-location and
runtime-observation fixtures too, so a TMPDIR containing `_` cannot make
them fail for the same reason as the cancellation test.

Refs #9996

The sibling sites are the ones #4484 switched.

Co-Authored-By: gensokyo-dev <[email protected]>
@N0zoM1z0

Copy link
Copy Markdown
Collaborator

Thank you! #10568 (rebase-merged) switched the same two fixtures, javascriptRuntimeObservation and javascriptRuntimeTargetLocations, to createNodeDiscoveryTempDirectory in 583bb47 (its commit message cites this PR), so this is now covered on main. Closing as superseded.

@N0zoM1z0 N0zoM1z0 closed this Nov 14, 2026
@morluto morluto added the area: tests Test suite and verification label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: tests Test suite and verification

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants