Skip to content

test(inspector): keep the target cancellation fixture path exactly reported - #7056

Closed
RishTheFish21 wants to merge 5 commits into
morluto:mainfrom
RishTheFish21:fix/inspector-cancel-test-macos-tmpdir
Closed

RishTheFish21 wants to merge 5 commits into
morluto:mainfrom
RishTheFish21:fix/inspector-cancel-test-macos-tmpdir

Conversation

@RishTheFish21

Copy link
Copy Markdown
Contributor

Summary

src/inspector/JavaScriptRuntimeScope.cancellation.test.ts › "stops Inspector target authorization after the current stat settles" fails on every macOS run of npm run test:fast.

Node's Inspector discovery reports a target's file path lossily: quotes, backslashes and underscores all come back as _. So authorizeRuntimeTargetLocation only stats a reported path that contains none of them, and otherwise records the target as unresolved (unverifiable-file-location) without touching the filesystem. The test builds its fixture under tmpdir(). On macOS that's a per-user directory like /var/folders/w3/_ypt96s55rl6vspl_7d6yjnw0000gn/T/, which contains underscores. Neither target is stat'ed, so the abort the test schedules on the second stat never fires, and listTargets succeeds.

The fix builds the fixture under a root that Node reports exactly: tmpdir() when it has none of those characters (Linux, unchanged), otherwise /tmp (/private/tmp on macOS).

No issue is linked. I found this running npm run test:fast on macOS.

Problem and expected behavior

Before, on macOS arm64 at main MAIN_SHA:

 FAIL   adapters  src/inspector/JavaScriptRuntimeScope.cancellation.test.ts > stops Inspector target authorization after the current stat settles
AssertionError: expected true to be false // Object.is equality
 ❯ src/inspector/JavaScriptRuntimeScope.cancellation.test.ts:140:21
    140|   expect(result.ok).toBe(false);

 Test Files  1 failed | 1022 passed (1023)
      Tests  1 failed | 18594 passed | 27 skipped (18622)

Expected: the test exercises what it names, on any POSIX host. The second target's stat settles, the abort lands, and the result is an AnalysisCancelledError carrying the one-target partial inventory.

Change and scope

  • Test-only: one helper in the test file picks the fixture root. Both tests in the file use it. The Electron test doesn't depend on the root, but it keeps passing.
  • Not changed: the lossy-path rule in JavaScriptRuntimeScope.ts is intentional (see tests/boundary/inspector/javascriptRuntimeTargetLocations.test.ts), and so is the rest of the product code.
  • Not included: Windows. On Windows this branch never stats a Node target, so the test can't exercise it there. I haven't changed how or whether Windows runs this file.

Follow the [contribution scope](https://github.com/morluto/rea/blob/main/CONTRIBUTING.md#contribution-scope).
Unresolved scope, authority, side effects, or required verification block
integration. Link the required maintainer scope decision for new providers or
capabilities involving target execution, injection, mutation, or protection
recovery; ordinary fixes within existing boundaries may state "not applicable".
Draft PRs may leave the scope decision pending and the readiness and merge checklists
unchecked. Maintainers can help resolve open questions.

Contract and boundary impact

  • Semantic owner and earliest changed stage: test fixture in src/inspector/JavaScriptRuntimeScope.cancellation.test.ts. No product stage changes.
  • Contribution scope fit and linked maintainer decision: Within existing boundaries (test fix). Maintainer decision not applicable.
  • CLI and MCP/tool-catalog contract: None.
  • Provider, bridge, target-format, or platform compatibility: None.
  • Evidence, artifact, provenance, or reconstruction contract: None.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): The fixture directory is still created with an owned rea- prefix and removed in afterEach.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs and skills/; edit authored instructions in .agents/skills/reverse-engineer-anything/ and never commit build outputs): None.

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: src/inspector/JavaScriptRuntimeScope.cancellation.test.ts (fixture root only).
  • Base reproduction or other evidence: the failure above, from npm run test:fast on macOS arm64. The cause follows from authorizeRuntimeTargetLocation, which checks /[_"\\]/u before stating a reported Node path, and from the macOS tmpdir() shown above.
  • User-visible CLI/MCP output (if applicable): none.
  • Remaining proof gaps: run on macOS arm64 only. On Linux, tmpdir() normally has no underscores, so the fixture root is unchanged there.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

macOS arm64, Node 24.22.1:

  • npm run test:focused -- src/inspector/JavaScriptRuntimeScope.cancellation.test.ts on main: RESULT_BEFORE
  • the same command with this change: RESULT_AFTER
  • npm run check:fast: RESULT
  • npm run format:check: RESULT

Compatibility, safety, and release

  • Breaking changes or migration steps: None.
  • Real Hopper/Ghidra, browser, or OS coverage: macOS arm64 test run.
  • Package or release metadata impact: None.
  • Security, privacy, process, or containment review: Test-only. The fixture writes two inert files under an owned temporary directory and removes them.

Author readiness

Human owner: @RishTheFish21

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-26T22:26:45.805168Z defd961 New commits
ℹ️ 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.

@greptile-apps

greptile-apps Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge; no actionable issues were found.

Summary

The PR shares a temporary-directory helper across Inspector tests so fixture paths remain exactly reportable on macOS.

  • Inspector tests use fixture paths Node can report exactly.

Reviews (5) · Last reviewed commit: "ci: rerun on current main" · Reviewed by Greptile

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 320e072d98

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

// usually contain `_`; use a root that Node reports exactly.
const exactlyReportedRoot = async (): Promise<string> => {
const temporary = await realpath(tmpdir());
return /[_"\\]/u.test(temporary) ? await realpath("/tmp") : temporary;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Leave Windows fixtures on the platform temp root

On a native Windows checkout with a normal C:\... temp path, the regex always takes this branch and realpath("/tmp") targets a drive-root tmp directory that generally does not exist, so targetFile() rejects before the test body runs. This is broader than the unsupported Node-target scenario: the four Electron/file-authorization tests later in this file all share targetFile() and previously used the valid result of tmpdir(), so focused Windows runs lose those cancellation, shutdown, and authorization regressions. Gate this fallback to POSIX and handle or skip only the Node-target case on Windows.

AGENTS.md reference: AGENTS.md:L83-L83

Useful? React with 👍 / 👎.

@morluto

morluto commented Oct 26, 2026

Copy link
Copy Markdown
Owner

Thanks for diagnosing the macOS cancellation fixture failure. #4484 addresses the same lossy Node discovery paths in other inspector tests and proposes a shared temporary-directory helper. Could you coordinate on using one fixture owner while keeping this distinct cancellation regression? Both PRs remain open.

Kenmege and others added 4 commits October 26, 2026 18:23
… 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]>
Main replaced the fixture module's local prefix check with
normalizeTestTemporaryPrefix, so the Node discovery helper uses it too and
keeps the same owned rea- naming as createTestTempDirectory.
…ported

Node discovery reports file paths with quotes, backslashes and underscores
replaced by `_`, so on POSIX REA leaves such a target unresolved without a
stat. The Inspector target cancellation test built its fixture under
tmpdir(), which on macOS is a per-user directory that usually contains `_`.
No stat ran, the cancellation never fired, and the test failed on macOS.
Build the fixture with createNodeDiscoveryTempDirectory, and skip the
Node-target case on Windows, where REA never stats a Node discovery path.
@RishTheFish21
RishTheFish21 force-pushed the fix/inspector-cancel-test-macos-tmpdir branch from 5eca3e5 to defd961 Compare October 26, 2026 22:26
@RishTheFish21

Copy link
Copy Markdown
Contributor Author

Thanks. Agreed, there should be a single fixture owner. I’ve reworked this PR to stack on #4484:

Once #4484 merges, this PR reduces to that last commit. If #4484’s author would rather rebase it themselves, I’ll rebase onto their branch instead. The cancellation regression stays separate either way.

Validation at defd961 (macOS arm64, Node 24.22.1): npm run test:focused on the cancellation test and both #4484 inspector files passed; check:fast and format:check passed.

@morluto

morluto commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Thank you @RishTheFish21! This fix has already landed on main via commit f35b6a75b3 (test(inspector): keep the cancellation fixture out of underscored temp roots) and was further consolidated in #10680 (commit 559956cf6b), where src/inspector/JavaScriptRuntimeScope.cancellation.test.ts uses createNodeDiscoveryTempDirectory from tests/fixtures/temporaryDirectory.ts. Closing as already landed.

@morluto morluto closed this Nov 24, 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