Skip to content

fix(javascript): report present non-JavaScript require targets as unavailable - #2642

Closed
cyberpunk47 wants to merge 8 commits into
morluto:mainfrom
cyberpunk47:fix/javascript-present-non-js-targets
Closed

cyberpunk47 wants to merge 8 commits into
morluto:mainfrom
cyberpunk47:fix/javascript-present-non-js-targets

Conversation

@cyberpunk47

@cyberpunk47 cyberpunk47 commented Oct 13, 2026 •

Copy link
Copy Markdown

Summary

Fixes #2641

analyze-javascript-application reported resolution_status: "not-found" for a module target that exists in the analysed artifact when the file is outside the JavaScript-relevant kinds (for example a bytenode .jsc module). The output was identical to a really missing file, and the edge evidence stated that no candidate exists in the inventoried container. This change keeps the inventory identity of such files and reports them as unavailable, with a limitation naming their sha256 and size. Missing files still report not-found.

Problem and expected behavior

Smallest trigger: a directory with main.js containing const core = require("./core.jsc") and a core.jsc file next to it.

  • Before: resolution_status: "not-found", with the limitation "No extension, directory package, or index candidate exists in the inventoried artifact container."
  • After: resolution_status: "unavailable", with the limitation "core.jsc exists in the inventoried artifact container (sha256 …, N bytes) but is not a JavaScript, JSON, HTML, source map, or native add-on file; its contents were not analyzed."

Violated invariant (AGENTS.md): "Unresolved identity or applicability must remain unknown rather than be treated as absent, foreign, or aligned."

Change and scope

  • Producing boundary: src/artifacts/javascript/JavaScriptArtifactFiles.ts skipped inventoried regular files with no relevant kind (if (kind === undefined) continue;) and left no record. It now records them as unanalyzed_files (path, container sha256, sha256, bytes, inventory artifact id) on JavaScriptArtifactFileSet. Their bytes are still never read.
  • JavaScriptArtifactPathResolution.resolveFileCandidates checks those records in the same candidate order as before, keeping the same-container rule. A match returns unavailable instead of falling through to not-found.
  • The graph context carries unanalyzedFilesByPath, and every resolveArtifactPathByContext call built from the context passes it.
  • Not included: no new status value, no contract or schema change, no change to graph-level coverage, and no reading or decoding of bytecode.

Contribution scope: not applicable (routine fix within existing boundaries).

Contract and boundary impact

  • Semantic owner and earliest changed stage: JavaScript artifact file projection (JavaScriptArtifactFiles), then path resolution
  • Contribution scope fit and linked maintainer decision: routine evidence-correctness fix; not applicable
  • CLI and MCP/tool-catalog contract: no schema change; the existing unavailable status is now used for this case
  • Provider, bridge, target-format, or platform compatibility: none
  • Evidence, artifact, provenance, or reconstruction contract: present-but-unanalysed targets keep their inventory identity in the limitation instead of being reported absent
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): not applicable
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none

Expected effects:

  • 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/application/javascript/JavaScriptArtifactPathResolution.test.ts: require and import targets present outside the projection give unavailable; a target in another container stays not-found; a missing target stays not-found.
    • tests/boundary/filesystem/javascriptRequireLiteralPaths.test.ts: real directory analysis; a present .jsc gives unavailable with its sha256 and size, and the same layout without the file gives not-found.
  • Base reproduction or other evidence: with only the test changes applied to the base revision, the boundary test and both unavailable unit tests fail; the two not-found guard tests pass.
  • User-visible CLI/MCP output (if applicable): see the before/after limitation text above.
  • Remaining proof gaps: graph-level coverage.status remains complete; whether it should change is left to maintainer preference (asked in the issue).

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

  • npx vitest run src/application/javascript src/artifacts src/domain/javascript: 76 files, 1547 tests passed
  • npm run test:focused -- <43 JavaScript boundary test files>: 565 passed, 1 skipped, 1 failed. The failure (packageImportAliases.test.ts, "matches literal imports keys containing path-like bytes in both Node loaders") fails identically on the unmodified base under Node 22.22 (Node returns ERR_INVALID_MODULE_SPECIFIER) and is unrelated to this change.
  • npm run check:fast: typecheck and lint passed
  • oxfmt --check on changed files: passed
  • Manual CLI run on the issue's sample: ./core.jsc reports unavailable; with the file deleted it reports not-found.

Compatibility, safety, and release

  • Breaking changes or migration steps: none. Consumers that treat every non-resolved status as unresolved are unaffected; consumers matching not-found specifically will now see unavailable for present, unanalysed targets.
  • Real Hopper/Ghidra, browser, or OS coverage: not applicable (static JavaScript analysis only); verified on Linux x64 with Node.js 22.22 and 22.23.
  • Package or release metadata impact: none
  • Security, privacy, process, or containment review: no new reads of file contents and no execution; only inventory metadata the artifact inventory already holds (path, sha256, size) is reported.

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 13, 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 ✅ Completed 2026-10-13T19:07:28.306169Z 1366b77 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 13, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Medium impact] Changes how JavaScript module resolution reports unavailable files.

The PR still needs the utility-entrypoint summary fix before merging.

Findings

  1. P1 Utility counts disagree ▶
Fix with agent prompt
### Issue 1
src/application/javascript/ElectronBoundaryGraphWindows.ts:undefined-243
`addUtilityProcess` now uses `unanalyzedFiles`, but `summarizeElectronBoundaries` still resolves utility entrypoints using only analyzed files. With `utilityProcess.fork("./worker")`, an extensionless opaque `worker`, and `worker.js`, the graph reports `unavailable` for `worker`. The summary instead selects `worker.js` and counts the launch in `electron_summary.resolved_utility_entrypoints`, giving users conflicting answers in one result.

Pass the same inventory lookup to the summary and add a regression that checks both outputs.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

The PR preserves inventory facts for files outside the JavaScript source projection and reports matching targets as unavailable instead of missing.

  • JavaScript links identify present files the analyzer cannot inspect.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Artifact inventory] --> B[JavaScript source projection]
  A --> C[Lazy lookup for unanalyzed files]
  B --> D[Shared path resolver]
  C --> D
  D --> E{Same-container candidate}
  E -->|Analyzed file| F[Resolved]
  E -->|Unanalyzed file| G[Unavailable with inventory facts]
  E -->|No candidate| H[Existing missing or external result]
  F --> I[Application graph]
  G --> I
  H --> I
Loading

Reviews (8) · Last reviewed commit: "Merge branch 'main' into fix/javascript-..." · 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: 822e466066

ℹ️ 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".

@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: d404bbdfac

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@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: 10746e3c3f

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Review findings addressed at their producing boundaries and consumers. Latest changes were reviewed from source; tests and provider runs were skipped at the maintainer's request. Findings requiring separate decisions or verification remain open.

  1. thread 1

Source changes are on 10746e3. Separated candidate identity lookup from loader/declaration policy. Exact ESM declaration imports use the shared identity owner and preserve the existing resolved contract; only declaration fallbacks get the unavailable runtime outcome. The pre-existing explicit .d.ts/.d.mts/.d.cts assertions remain intact.

Source inspection and git diff checks completed. Tests, typecheck/lint, generated-schema checks and real-provider lanes were not run for this final revision at the user's explicit request.

  1. thread 1

Source changes are on 10746e3. Opaque classification now excludes verified expanded container identities rather than every .asar suffix. Ordinary ASAR members retain inventory identity and exact-candidate precedence over later .js candidates. Added an outer-ASAR production regression containing ordinary.asar and ordinary.asar.js.

Source inspection and git diff checks completed. Tests, typecheck/lint, generated-schema checks and real-provider lanes were not run for this final revision at the user's explicit request.

  1. thread 1

Source changes are on 10746e3. Replaced occurrence/node linear scans with binary lower-bound lookup over canonical snapshot arrays. Prefix queries examine only their contiguous directory range, and requested candidates/directory outcomes remain cached for the immutable reconstruction lifetime. Expanded-container ownership uses verified container facts, without eager metadata copies for every opaque asset. Resource/time/token costs remain unmeasured after the requested verification stop.

Source inspection and git diff checks completed. Tests, typecheck/lint, generated-schema checks and real-provider lanes were not run for this final revision at the user's explicit request.

  1. thread 1

Source changes are on 10746e3. The owning lookup now reuses the snapshot arrays already sorted by code-point logical path and artifact ID; first misses and positive metadata lookup use binary search rather than whole-inventory scans. Directory queries use a bounded prefix range and retain only requested query results. The snapshot order invariant is documented at its domain owner; no all-assets metadata map is allocated.

Source inspection and git diff checks completed. Tests, typecheck/lint, generated-schema checks and real-provider lanes were not run for this final revision at the user's explicit request.

  1. thread 1

Source changes are on 10746e3. Source-map observations and maps_to edges now retain the full contextual resolution: status, candidate path and original limitations. Present opaque candidates preserve their digest/size evidence; absent, external and wrong-projection outcomes no longer collapse into the false not-present message. Added a boundary regression for an opaque sourceMappingURL target.

Source inspection and git diff checks completed. Tests, typecheck/lint, generated-schema checks and real-provider lanes were not run for this final revision at the user's explicit request.

@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: 73534cf2d4

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Review findings addressed at their producing boundaries and consumers. Latest changes were reviewed from source; tests and provider runs were skipped at the maintainer's request. Findings requiring separate decisions or verification remain open.

  1. thread 1

Changes are on 73534cf. Opaque presence was incorrectly conditional on a content digest. The borrowed lookup now admits known regular-file occurrences with null artifact IDs, retains nullable digest/size and the inventory's limitations, and includes them in directory presence. The shared resolver reports unavailable and unknown digest instead of not-found or ancestor fallback.

Source validation: Authored an unexecuted ASAR missing-unpacked-companion regression covering both graph projections. Reviewed container identity and nearest-package lookup; no invented digest or content-addressed identity is produced. Tests, checks, builds, lint/typechecks, provider workloads and CI reruns were not run at the user's explicit request. Targeted formatting used the pinned Node toolchain with two formatter threads.

  1. thread 1

Changes are on 73534cf. Worker resolution returned null before its unavailable facts could reach the graph. Resolution now survives independently of an optional asset node; worker/service-worker observations and launch edges retain status, candidate and limitations. Missing and opaque targets stay distinguishable.

Source validation: Authored an unexecuted worker/service-worker graph regression. Reviewed the ordinary module path and nullable worker target; no orphan placeholder module is created for an unavailable worker. Tests, checks, builds, lint/typechecks, provider workloads and CI reruns were not run at the user's explicit request. Targeted formatting used the pinned Node toolchain with two formatter threads.

  1. thread 1

Changes are on 73534cf. Utility-process resolution ran after the observation and launch edge and was dropped when no asset link existed. It now runs once before projection; a separate inference observation and launch edge retain status/candidate/limitations while the original AST observation preserves its observed authority.

Source validation: Authored an unexecuted utility-process graph regression. Reviewed the optional maps_to edge and shared path-resolution owner; no raw path is reinterpreted downstream. Tests, checks, builds, lint/typechecks, provider workloads and CI reruns were not run at the user's explicit request. Targeted formatting used the pinned Node toolchain with two formatter threads.

@morluto morluto added bug Something isn't working area: domain Domain logic, errors, and pure functions area: evidence Evidence, artifacts, and reconstruction P2: medium Medium priority issue labels Oct 13, 2026

@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: b5ed98b029

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Source fixes and publication evidence for the review findings below. Tests and executable checks were skipped at the maintainer's request. Findings that still require a decision or execution evidence remain open.

review thread

Fixed publicly in b5ed98b. Package-role projection now retains opaque candidate paths instead of dropping them at the structure boundary; the consumer and fixture coverage preserve those candidates through graph construction. Source inspection covered the producer and graph consumers; git diff --check passed. Tests, builds, lint, typechecks, provider workloads and CI reruns were skipped at the user's explicit request. No directly related cleanup remains.

Finding addressed: Useful? React with 👍 / 👎..

@morluto

morluto commented Oct 13, 2026

Copy link
Copy Markdown
Owner

Source fixes and publication evidence for the review findings below. Tests and executable checks were skipped at the maintainer's request. Findings that still require a decision or execution evidence remain open.

review thread

Changes are present at public head 9834235c1c981e933d4556bfd89f7eec8d0c548a. A regular archive file that was also listed as a container was excluded from exact-path lookup. The public predicate keeps exact regular-file occurrences opaque while reserving container mapping for descendants. Reviewed resolver candidate and descendant handling; git diff --check passed, no tests run.

sourcePath: file.path,
context: value.module_resolution_context,
files: context.filesByPath,
unanalyzedFiles: context.unanalyzedFiles,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Utility counts disagree

addUtilityProcess now uses unanalyzedFiles, but summarizeElectronBoundaries still resolves utility entrypoints using only analyzed files. With utilityProcess.fork("./worker"), an extensionless opaque worker, and worker.js, the graph reports unavailable for worker. The summary instead selects worker.js and counts the launch in electron_summary.resolved_utility_entrypoints, giving users conflicting answers in one result.

Pass the same inventory lookup to the summary and add a regression that checks both outputs.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/application/javascript/ElectronBoundaryGraphWindows.ts
Line: 243

Comment:
**Utility counts disagree**

`addUtilityProcess` now uses `unanalyzedFiles`, but `summarizeElectronBoundaries` still resolves utility entrypoints using only analyzed files. With `utilityProcess.fork("./worker")`, an extensionless opaque `worker`, and `worker.js`, the graph reports `unavailable` for `worker`. The summary instead selects `worker.js` and counts the launch in `electron_summary.resolved_utility_entrypoints`, giving users conflicting answers in one result.

Pass the same inventory lookup to the summary and add a regression that checks both outputs.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

@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: 97a79c05d1

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

analysis,
root,
filesByPath: new Map(fileSet.files.map((file) => [file.path, file])),
unanalyzedFiles: fileSet.unanalyzed_files,

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 Carry the opaque lookup into Electron summary resolution

When utilityProcess.fork("./worker") is analyzed with both an extensionless opaque worker and worker.js, the graph context added here correctly stops at worker with unavailable, but JavaScriptArtifactReconstruction.ts:255 still calls summarizeElectronBoundaries(analysis) without this lookup; ElectronBoundaryAnalysis.ts:155-163 consequently skips worker, resolves worker.js, and increments resolved_utility_entrypoints while the graph reports the entrypoint unavailable. Pass fileSet.unanalyzed_files through the summary resolver as well.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

morluto added a commit that referenced this pull request Oct 14, 2026
Normalize path facts once at the owning filesystem boundary, preserve caller spelling and unavailable inventory members, and retain typed read failures. Record exclusion entry kinds so only proven directories can establish descendant symlink targets; omitted legacy kinds stay unknown.

Reviewed fixes include #1969, #2642, #2759, and #2994.

Validation: 26 reference graph source tests passed; prior artifact checks passed 275 tests with one Windows-only skip. Updated compiled import workflows are included in final validation after regeneration.
morluto added a commit that referenced this pull request Oct 14, 2026
Preserve CommonJS literal paths and confined ESM URL semantics, including package main fallback, directory intent, Unicode identity, and present opaque modules. Parse extraction inputs at their AST/source owner, retain skipped HTML and source-map coverage, and distinguish endpoint candidates from proven receiver facts. Version structural fingerprints with computed literal contents and propagate them through worker contracts.

Reviewed fixes include #1810, #1840, #2642, #2700, #2702, #2714, #2803, #2960, #2968, #2986, #3035, and #3036.

Validation: 158 resolver tests passed; public CLI/MCP module lookup controls, package-main/Unicode workflows, and six builtin workflows passed in the current compiled lane. Worker schema/fingerprint regressions passed. Large public pdf.js completion and real Electron analysis remain unverified.
@cyberpunk47

Copy link
Copy Markdown
Author

Source fixes and publication evidence for the review findings below. Tests and executable checks were skipped at the maintainer's request. Findings that still require a decision or execution evidence remain open.

review thread

Changes are present at public head 9834235c1c981e933d4556bfd89f7eec8d0c548a. A regular archive file that was also listed as a container was excluded from exact-path lookup. The public predicate keeps exact regular-file occurrences opaque while reserving container mapping for descendants. Reviewed resolver candidate and descendant handling; git diff --check passed, no tests run.

This appears to be covered on main by b58adaf. Is anything further needed here, or can this be closed?

@CassieFox23

Copy link
Copy Markdown
Contributor

Heads up: main already has this change in b58adaf. The code is in src/application/javascript/JavaScriptArtifactPathResolution.ts, and reports a present non-JavaScript require target as unavailable with inventory identity covers it. It is listed on tracker #3582. If this PR still adds something main doesn't have, please say so here and I'll take it off the list. Thanks for the fix!

🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊

@morluto

morluto commented Oct 15, 2026

Copy link
Copy Markdown
Owner

Superseded by the delivered change on main: b58adafa4. Present non-JavaScript require targets retain unavailable status and candidate identity rather than becoming not-found. Current inventory/path tests also distinguish genuinely missing files; this does not claim decoding support. Closing this earlier proposal. Current main qualification passed: https://github.com/morluto/rea/actions/runs/38690953281.

@morluto morluto closed this Oct 15, 2026
@morluto

morluto commented Oct 15, 2026

Copy link
Copy Markdown
Owner

Thank you @cyberpunk47 for distinguishing a present but opaque .jsc file from a module that cannot be found. Main preserves that unavailable-versus-absent distinction in module resolution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: domain Domain logic, errors, and pure functions area: evidence Evidence, artifacts, and reconstruction bug Something isn't working P2: medium Medium priority issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] analyze-javascript-application reports an existing bytenode .jsc require target as not-found

4 participants