Repository navigation
fix(javascript): preserve incoming callback target uncertainty - #4243
Conversation
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
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 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".
[Medium impact] The PR appears safe to merge; the previous branch-growth finding is addressed and no new blocking issue was found. SummaryThe PR preserves uncertainty when a conditional assignment may leave an incoming callback unchanged. Call resolution and returned-reference effects share facts about each read.
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]
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.
There was a problem hiding this comment.
💡 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.
…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
Summary
Fixes #3880.
if (flag) cb = fallback; return cb()previously produced a resolved edge tofallback, although Node calls the incoming callback whenflagis 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
semanticBindingAtReadowner 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
Expected effects:
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
2b26094f4and fixed inbd567c491: 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.Validation performed
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:
Tokens use
cl100k_baseover 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
bd567c491grows 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.
Before merge
type(scope): outcome.