Skip to content

fix(javascript): preserve incoming callback target uncertainty - #4243

Merged
N0zoM1z0 merged 3 commits into
mainfrom
fix/javascript-callback-entry-3880
Oct 16, 2026
Merged

N0zoM1z0 merged 3 commits into
mainfrom
fix/javascript-callback-entry-3880

Conversation

@N0zoM1z0

@N0zoM1z0 N0zoM1z0 commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes #3880. if (flag) cb = fallback; return cb() previously produced a resolved edge to fallback, although Node calls the incoming callback when flag is false. It now retains a candidate edge and an ambiguous, partial default trace. A proven unconditional replacement remains resolved.

Problem and expected behavior

A known local candidate is not necessarily an exhaustive target set. Assignment timing also matters: later writes must not change an earlier callback read or captured alias.

Change and scope

Use the existing semanticBindingAtRead owner for callable resolution and returned-reference effects. Its definite-initializer proof distinguishes writes dominating a read from globally conditional writes. Cache by identifier read, and track active parsed initializer facts so saved/restored values are not mistaken for binding cycles. Memoize cycle-independent partial callable results. Returned references use one projected traversal: finish subgraphs before caching them, keep actual cycle blockers as dependencies, and propagate those dependencies through cache hits. The redundant preliminary callable traversal and its cache are removed.

Unproved branch/activation ordering stays conservative; this does not add a control-flow interpreter.

Contract and boundary impact

  • Semantic owner: JavaScript call resolution; returned-reference consumers share the same read-position facts.
  • Contribution scope: ordinary correctness/performance fix within existing static analysis; additional maintainer scope decision not applicable.
  • CLI/MCP: shared implementation; no schema or catalog changes.
  • Evidence: retains known candidates, source identity and uncertainty; complete parent Evidence remains queryable after summary replies.
  • Providers/platforms: Linux Node 24.18.0; no provider, installer or package changes.
  • Target authority/cleanup: analysis reads authored source files. Node execution is confined to the test oracle.

Expected effects:

  • Read existing files or captured data.

Evidence and regression coverage

Both public acceptance tests fail on pinned main 0cc56493b: the conditional callback is falsely resolved, and a later replacement falsely contaminates an earlier returned-reference effect. Both pass with this change through CLI and real stdio MCP.

Authored Node runtime controls cover conditional/logical replacement, catch/default parameters, delayed nested writes, captured callbacks, before/after reads and definite local replacement. Domain tests check read-cache isolation, read-specific initializer coverage, genuine cycle-context reuse and bounded reconvergent partial-alias work in both consumers (depth 8 versus 12).

Both actionable review findings were reproduced against original PR head 2b26094f4 and fixed in bd567c491: guarded calls now remain resolved, and restoring a saved callback retains its target/reference effects. Node returns 3 after mutating a returned shared object; the original head falsely reports literal 1, while the fix preserves unknown mutation evidence.

  • 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

  • All JavaScript domain tests plus the new public acceptance file: 1,835 passed / 76 files.
  • npm run check: passed, including lint, module boundaries and architecture guards.
  • npm run docs:check: passed, including 5 documentation consistency tests.
  • npm run verify:test-discovery: all 1,363 test files discovered exactly once.

On the final head, three alternating fresh MCP sessions per version completed the same 10-call workflow: summary analysis, seven retained traces, explicit candidate traversal and full Evidence bundle verification. Median baseline → fix:

Measurement Baseline Fix
Completed workflow wall / CPU 10.045 / 11.714 s 9.881 / 11.597 s
Sampled process-family peak RSS 945 MiB 953 MiB
Cold completed goal 9.635 s 9.466 s
Warm retained trace 6.89 ms 5.88 ms
First goal token proxy, including catalog 808,379 806,848
Complete workflow token proxy 911,527 900,547

Tokens use cl100k_base over the full SDK catalog (798,856 tokens in both), all request/reply JSON including text/structured duplication, extra calls and full bundle. These are context proxies; initialization/wire framing/model billing are unmeasured. Correct candidate filtering changes returned content; these small timings do not establish a general speedup. Shared host; two pinned cores, 3 GiB Node heap, serial heavy jobs. RSS sampled every 200 ms may count shared pages twice or miss brief peaks; CPU covers reaped descendants. Largest local gate sample was 4.69 GiB, with no OOM or resource-limit stop. Logs, failed probes and measurements are retained locally under /tmp/rea-3880-20261015.

Separate branch-assignment growth controls (including an intrinsic cycle and projected method calls) protect the reference traversal itself. A regression against bd567c491 grows from 1,042 to 16,410 binding reads at depth 8→12; it fails before the fix. Empty-local ||=/??= controls also fail there and pass now, while initialized/incoming aliases stay conservative.

Cold public CLI plus Node-oracle verification at depth 12: 6.620→2.411 s wall, 7.503→3.021 s CPU, 447→448 MiB RSS against bd567c491. Full Evidence is exactly equal at depths 8/12. Fixed depths 20/32 complete in 2.501/2.545 s, about 445 MiB peak; the old version was not run at those sizes. These are single shared-host samples. All original-task SDK payloads also match the previously verified fix.

Compatibility, safety, and release

No new API, migration, provider or execution capability. Real-provider coverage is not applicable to this static JavaScript fix. Cross-branch/activation precision remains limited; uncertainty is preserved.

Author readiness

Human owner: @N0zoM1z0

The human owner explicitly authorized delegated review, proxy completion of these declarations, ready-for-review publication and normal merge for this batch. The agent reviewed the final diff and evidence; this records that delegation and does not assert a separate manual review occurred.

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

Resolve rebound call targets at their read position, retaining skipped-write
and activation-order uncertainty alongside known local candidates. Key the
query-local cache by identifier reads and memoize cycle-independent partial
results to bound shared alias expansion.

Use the same read facts for returned-reference effects. Verify public CLI,
retained stdio MCP traces and authored Node runtime controls.

Fixes #3880
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 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-15T21:39:48.634519Z f6b7bf4 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.

@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: 2b26094f4d

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

@greptile-apps

greptile-apps Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; the previous branch-growth finding is addressed and no new blocking issue was found.

Summary

The PR preserves uncertainty when a conditional assignment may leave an incoming callback unchanged. Call resolution and returned-reference effects share facts about each read.

  • The latest change replaces branch-history caching with completed expansions that track actual cycle blockers.
  • Previous finding Add dynamic binary sessions and guided onboarding #1 is addressed. No new actionable issues or security findings were confirmed.
  • Tests were inspected, not executed during this review.
  • A live check for a superseding PR was blocked because GitHub CLI authentication was unavailable.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  Read[Callback read] --> Facts[Select initializers at this read]
  Facts --> Calls[Resolve callable candidates]
  Calls --> Covered{A write definitely covers the read?}
  Covered -->|Yes| Resolved[Keep proven resolution]
  Covered -->|No| Partial[Retain candidates and uncertainty]
  Facts --> References[Walk returned-reference targets]
  References --> Complete[Finish descendants]
  Complete --> Cache[Cache actual cycle blockers]
Loading

Reviews (3) · Last reviewed commit: "fix(javascript): bound projected callbac..." · Reviewed by Greptile

Publish definite initializer coverage from the shared read owner so writes
dominating calls in a conditional block remain resolved. Track active parsed
initializer facts in callable and returned-reference traversal, allowing an
earlier callback snapshot to be restored without a false binding cycle.

Verify both review findings through public CLI/MCP and Node controls; retain
logical-write uncertainty and genuine cycles, and bound shared partial alias
expansion in both consumers.

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

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

Finish reference subgraphs before caching them and retain only actual cycle
blockers as reuse dependencies. Propagate blockers through cache hits, keep
initializer-version cycle checks, and remove the redundant callable pass.

Preserve definite empty-local logical writes without discarding existing
aliases. Keep entry coverage independent of uncertain latest-write order.

Verify public CLI/MCP and Node controls, separate branch assignments with
and without intrinsic cycles, and fixed-input correctness/performance.
@N0zoM1z0
N0zoM1z0 merged commit 42fc6c5 into main Oct 16, 2026
34 checks passed
@N0zoM1z0
N0zoM1z0 deleted the fix/javascript-callback-entry-3880 branch October 16, 2026 02:09
Iyanuoluwa007 pushed a commit to Iyanuoluwa007/rea that referenced this pull request Oct 21, 2026
…resolution


morluto#4243 moved local call resolution from binding-level to initializer-level
cycle detection. Results inside a cycle are cycle-dependent and never cached,
so a mesh of mutual reassignments whose reads select every write enumerated
every initializer order: 12 writes took 1.5 s and each further pair ~35x more.

A read that selects every initializer resolves the same candidates wherever
the chain re-enters it, and a longer chain only cuts more of them, so closing
that cycle at the binding adds no callable and keeps the mesh linear (12
writes: 5 ms). Position-narrowed reads keep their per-initializer cycles.

Refs: morluto#4348
@fabio-dee fabio-dee mentioned this pull request Oct 22, 2026
@morluto morluto added bug Something isn't working area: native Native analysis and decompilation, including Ghidra, IDA, and Hopper analysis behavior labels Nov 23, 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.

[Bug] A conditionally replaced callback parameter becomes a resolved local call

3 participants