Skip to content

fix(elixir): capture calls made from single-line def …, do: bodies - #2970

Open
rajatnagda45 wants to merge 1 commit into
Graphify-Labs:v8from
rajatnagda45:fix/elixir-inline-do-calls
Open

rajatnagda45 wants to merge 1 commit into
Graphify-Labs:v8from
rajatnagda45:fix/elixir-inline-do-calls

Conversation

@rajatnagda45

Copy link
Copy Markdown
Contributor

What

Calls made from Elixir's single-line keyword function form are silently dropped from the graph.

def f(x), do: g(x) — the idiomatic one-liner — stores its body as a do: pair inside the call's arguments (keywords → pair → keyword "do:" + value), not as a do_block. The extractor only registered a body for the call pass when it found a do_block child, so every call issued from a one-line function was never walked.

This form is pervasive in real Elixir (short delegating functions, defp helpers, guards), so a large slice of the intra-module call graph goes missing.

Reproduce

defmodule Calc do
  def add(a, b), do: a + b
  def line_caller(x), do: add(x, 1)   # calls edge to add/2 was dropped
  def block_caller(x) do
    add(x, 2)                          # this one was captured
  end
end

Before this change only block_caller → add was emitted; line_caller → add was missing.

Fix

When a def/defp has no do_block, look for the do: keyword pair in its arguments and register that value node for the existing call-walking pass. The multi-line do..end path is untouched.

Tests

Adds test_elixir_single_line_do_body_emits_calls, asserting the one-line caller now emits its calls edge while the do..end form keeps working. Full suite green locally (4822 passed, 0 failed).

…calls are captured

The extractor only registered a function body for call-walking when the `def`
had a `do_block` child. The one-line keyword form -- `def f(x), do: g(x)`,
which is idiomatic and pervasive in Elixir -- stores its body as a `do:` pair
inside the call's `arguments` (`keywords` -> `pair` -> `keyword` "do:" + value),
so every call made from a one-line function was silently dropped from the graph.

Register the `do:` keyword value for the call pass when no `do_block` is present.
The multi-line `do..end` form is unchanged.

Adds a regression test asserting the one-line caller emits its `calls` edge while
the do..end form keeps working.

@graphify-labs graphify-labs 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.

Graphify reviewed this change.

Worth a look — the grounded gate found no coupling regressions or blocking issues, but 1 advisory finding(s) below merit a look before merge.

Formal verification. No changes could be formally verified in this run.


Graphify review — findings

Adds _keyword_do_body to the Elixir extractor so single-line def f(x), do: expr functions have their body walked for call edges, not just do_block forms. Covers it with test_elixir_single_line_do_body_emits_calls, asserting the one-liner and do..end forms both emit calls.

Worth a look

  • Keyword do bodies are not handled for single-line defmodule forms — graphify/extractors/elixir.py · Escalate · medium
    • agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 523 functions depend on the 523 functions this change touches.

Health — this change adds coupling hotspots:

  • new: extract_elixir() — 11 callers, 5 callees
  • new: walk() — 1 callers, 6 callees

Verification — 523 functions in the blast radius were not formally verified this run (proofs are advisory here).

Gate & verification

graphify gate

PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.

Advisory (not blocking):

  • verification_scope: 523 function(s) in the blast radius were not formally verified this run

Formal verification

Could not verify: Could not verify extract\_elixir.

The verifier did not have enough to check extract\_elixir, so it is saying so rather than guessing. No false assurance is the whole point.

Guarantee: No guarantee either way, this is an honest abstention, not a pass.

Note: Reason: parameter `path` is annotated `Path` — outside the synthesizable primitive/collection set

· 1 grounded finding(s) anchored inline below; 1 more finding(s) on lines outside this diff (see the check run).

return value
return None

def walk(node, parent_module_nid: str | None = None) -> None:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Health regression — walk()

fans out to 6 callees (efferent coupling).

Grounded coupling-delta finding (deterministic), not an LLM guess.

This branch has not been deployed

No deployments
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.

1 participant