Skip to content

fix(semantics): link wrapped arrow Promise returns - #794

Closed
kaoru0822-kitauji wants to merge 2 commits into
morluto:mainfrom
kaoru0822-kitauji:fix/promise-arrow-return-range
Closed

kaoru0822-kitauji wants to merge 2 commits into
morluto:mainfrom
kaoru0822-kitauji:fix/promise-arrow-return-range

Conversation

@kaoru0822-kitauji

Copy link
Copy Markdown
Collaborator

Summary

Restore the return-site link for an expression-bodied arrow that directly returns a Promise through a TypeScript wrapper. This is a focused follow-up to #758; no separate issue is linked.

Problem and expected behavior

const run = () => (Promise.resolve(1) as Promise<number>); is correctly classified as returned ownership, but its returnSiteId is null. Consequently the semantic graph omits returns-task.

The ownership detector unwraps the body to identify the producer. Return collection records the original arrow body range, including its wrapper. Looking up the narrower producer range cannot find that existing return site.

Change and scope

Use the original arrow-body range for the return-site lookup after direct ownership has already been established. This is one production-line change. Promise recognition, ownership boundaries, producer locations and return-site identities are unchanged.

Contract and boundary impact

  • Semantic owner and earliest changed stage: pure JavaScript Promise ownership projection.
  • CLI and MCP/tool-catalog contract: no schema/catalog changes; the existing graph relation can now be emitted for the recovered return site.
  • Provider, bridge, target-format, or platform compatibility: no provider or runtime execution changes.
  • Evidence, artifact, provenance, or reconstruction contract: uses the existing exact return-site identity and source range.
  • Process execution, authorization, cleanup, or containment impact: none.
  • Generated metadata, package, or installation impact: none.

Evidence and regression coverage

  • On d2aed17, the completed two-file regression suite has 16 failures and 35 passing controls. Failures are missing return-site IDs and graph relations.

  • Fixed focused suites pass 70 tests, also rerun after fast-forwarding to b62931f.

  • Covers as, satisfies, non-null and nested wrappers; nested arrows; constructor, aggregate and chained producers; bare/parenthesized bodies and explicit return statements.

  • Enclosing calls, arrays, objects, conditionals and sequences stay unknown; awaited producers do not gain a return link.

  • Graph tests traverse the actual returns-task relation through queryJavaScriptSemanticGraph.

  • This is source-analysis and graph/query proof, not real JavaScript execution or CLI/MCP end-to-end verification.

  • 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

  • npm run test:local -- src/domain/javascriptSemanticAnalysis.promise_ownership.test.ts src/application/JavaScriptSemanticGraphBuilder.test.ts src/domain/javascriptSemanticAnalysis.calls.test.ts src/domain/javascriptSemanticAnalysis.function_names.test.ts — 70 passed.
  • npm run check — passed, 125 existing warnings and zero errors.
  • npm run build:cached — passed.
  • npm run jscpd, npm run scan:todos, git diff --check — passed.
  • Node 24.19.0/npm 11.9.0, exact locked dependency versions.

Compatibility, safety, and release

No migrations or package metadata changes. No real Hopper/Ghidra/browser workflow was run or required for this pure static-analysis correction. Source is not executed. Independent review verified the final three-file patch; AI assisted implementation and testing.

Review checklist

  • One focused outcome and conventional title.
  • Related PR and reason for no separate issue are stated.
  • Regression and negative controls cover changed behavior.
  • No owning schema or generated metadata changes are needed.
  • Final diff checked for unrelated cleanup and unsupported claims.

Copy link
Copy Markdown
Collaborator Author

@codex review

@N0zoM1z0 N0zoM1z0 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.

Source review passed on head9830ad40e8. Direct returned Promise ownership already unwraps TS syntax; using the original arrow-body range now selects the exact existing return-site identity, while the producer location stays unchanged. Wrapped, nested-arrow, aggregate/chained and negative ownership controls passed in the focused suites. All19 exact-head hosted checks are green. No blocking source finding. Integration is currently blocked by a test-only conflict with merged#764 in JavaScriptSemanticGraphBuilder.test.ts; update that branch and rerun relevant checks before merge. No conflict resolution was performed in this review.

Resolve the test-only conflict with #764 by retaining both appended test blocks unchanged. Keep the wrapped Promise return correction and domain regressions unchanged.

Validation: 302 semantic and graph tests; 11 CLI acceptance tests; npm run check, build:cached, jscpd, scan:todos; independent conflict-resolution review.
@morluto

morluto commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Superseded by #815, which integrated this change and has now merged (3af3811). Thanks @kaoru0822-kitauji for the fix and tests — much appreciated!

@morluto morluto closed this Oct 7, 2026
morluto added a commit to rudycelekli/rea that referenced this pull request Oct 7, 2026
@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Oct 14, 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.

3 participants