Skip to content

feat: extract Python method body references for dependency graph#147

Merged
Zir0-93 merged 2 commits into
masterfrom
feat/python-method-body-refs
Jun 3, 2026
Merged

feat: extract Python method body references for dependency graph#147
Zir0-93 merged 2 commits into
masterfrom
feat/python-method-body-refs

Conversation

@Zir0-93

@Zir0-93 Zir0-93 commented Jun 3, 2026

Copy link
Copy Markdown
Member

Summary

  • daemon.js: Add collectBodyReferences() that walks the suite AST to find Call nodes and resolve their callees via resolveTypeFromRaw(). Skips nested Function/Class nodes. Results attached to both extractMethod() and extractFunction() return values.
  • PythonMethodModel: Add bodyReferences field (List<PythonTypeRefModel>)
  • PythonModelAssembler: Wire body refs as SimpleTypeReference entries in both buildMethodComponent() and buildFunctionComponent()

This dramatically increases relationship density for Python projects (~27 rels/component → potentially 100+), which was the root cause of Python's 0% match rate in the existential test.

Test plan

  • 5 new unit tests in PythonMethodBodyRefsTest — all passing
  • Full Python test suite (112 tests) passes
  • Verify on real Python repos (sqlmodel, werkzeug, jinja) that rel density increases

🤖 Generated with Claude Code

Add collectBodyReferences() to Python daemon that walks method/function
body AST to find Call nodes and resolve their callees. This dramatically
increases relationship density for Python projects (from ~27 to potentially
100+ rels/component), which was the root cause of Python's 0% match rate
in the existential test.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

@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: 828ffd45bb

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

Comment thread src/main/resources/python/daemon.js Outdated
Comment on lines +1704 to +1706
const resolved = resolveTypeFromRaw(calleeText, ctx);
if (resolved) {
refs.push({ raw: calleeText, targetUniqueName: resolved, externalLabel: resolved });

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid resolving instance calls as module functions

When the callee is a dotted expression, resolving the entire text through resolveTypeFromRaw makes ordinary instance calls look like module-level symbols whenever the receiver name matches a module in the package. In the added fixture, dao = UserDao(); dao.find_by_id(...) is emitted by the daemon as a targetUniqueName of src.dao.find_by_id (not the UserDao.find_by_id(...) method component), so after classification the method gains a bogus external dependency. This will pollute dependency graphs for common variable names like repo.save() or service.call() that happen to match sibling modules; dotted callees should only be resolved this way when the base is a known imported module/alias, not a local variable.

Useful? React with 👍 / 👎.

@codecov

codecov Bot commented Jun 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 38.46154% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.77%. Comparing base (452cd06) to head (58868a6).

Files with missing lines Patch % Lines
.../clarpse/compiler/python/PythonModelAssembler.java 33.33% 4 Missing and 4 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #147      +/-   ##
============================================
- Coverage     71.87%   71.77%   -0.11%     
- Complexity      903      904       +1     
============================================
  Files            65       65              
  Lines          4093     4106      +13     
  Branches        699      705       +6     
============================================
+ Hits           2942     2947       +5     
- Misses          723      727       +4     
- Partials        428      432       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…tives

Only resolve dotted callees (e.g. dao.find_by_id) when the base is a
known imported symbol or local class, not an arbitrary local variable.
This prevents variable names matching module names from creating bogus
external dependencies. Also bump version to 9.7.0.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Zir0-93
Zir0-93 merged commit 5a5f966 into master Jun 3, 2026
8 of 10 checks passed
@Zir0-93
Zir0-93 deleted the feat/python-method-body-refs branch June 3, 2026 02:55
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