Skip to content

Fix non-deterministic caller resolution in call graph tracking#16

Draft
Copilot wants to merge 3 commits into
mainfrom
copilot/investigate-issue-15
Draft

Fix non-deterministic caller resolution in call graph tracking#16
Copilot wants to merge 3 commits into
mainfrom
copilot/investigate-issue-15

Conversation

Copy link
Copy Markdown

Copilot AI commented Feb 16, 2026

On second rerun, get_rays() fails with assertion error despite identical inputs. Root cause: caller params_hash resolution iterates all graph nodes without breaking, using last match. When multiple nodes exist for the same function (after 2nd+ reruns), selection becomes non-deterministic.

Changes

  • Added execution stack to track active call chain in CallTracker

    • Push callee node on function entry
    • Pop on exit via try-finally for proper cleanup
  • Modified caller resolution to check stack first (top = current caller), fallback to graph search with break

  • Fixed caching logic to allow None return values (removed incorrect result is not None check)

Before/After

# Before: Non-deterministic, uses last node in iteration order
caller_params_hash = -1
for n in self._call_graph.nodes:
    if n.func == k:
        caller_params_hash = n.params_hash  # No break!

# After: Deterministic, uses active caller from stack
if self._execution_stack:
    caller_node = self._execution_stack[-1]
    if caller_node.func == k and caller_node.module == caller_module:
        caller_params_hash = caller_node.params_hash

The stack ensures correct caller identification when multiple nodes with same function exist in the graph.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits February 16, 2026 00:29
Co-authored-by: DubiousCactus <7703484+DubiousCactus@users.noreply.github.com>
Co-authored-by: DubiousCactus <7703484+DubiousCactus@users.noreply.github.com>
Copilot AI changed the title [WIP] Investigate issue number 15 Fix non-deterministic caller resolution in call graph tracking Feb 16, 2026
Copilot AI requested a review from DubiousCactus February 16, 2026 00:35
Base automatically changed from tui to main March 2, 2026 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants