Repository navigation
Description
Version
codebase-memory-mcp dev
Platform
Linux (x64)
Install channel
Built from source
Binary variant
standard
What happened, and what did you expect?
When Python receiver/type resolution does not identify a member-call target, the indexing pipeline falls back to name-based heuristics and emits an ordinary CALLS edge to an unrelated same-named method.
This produces structurally impossible edges, including production code calling test mocks and external-library calls being connected to unrelated project methods.
Representative results from one production function:
| Actual call | Stored target | Strategy / confidence |
|---|---|---|
accelerator.print(...) |
tests.unit.test_resume_logic.MockAccelerator.print |
field_type_hint, 0.85, 2 candidates |
accelerator.backward(...) |
library.models.sdxl.unet.FlashAttentionFunction.backward |
suffix_match, 0.28, 2 candidates |
trainer.lr_scheduler.step() |
library.pipelines.gradual_latent.EulerAncestralDiscreteSchedulerGL.step |
suffix_match, 0.01, 84 candidates |
The correct target for the first two calls is an external accelerate.Accelerator method. For the scheduler call, the concrete runtime scheduler cannot be established from this call site. None of these calls should be represented as a certain call to the selected target above.
I expected receiver-aware resolution when sufficient type evidence exists, and conservative behavior otherwise: either preserve the call as unresolved/ambiguous or omit the ordinary CALLS edge. A same-named project method should not become the target solely because the actual receiver type is unknown or external.
This is the Python equivalent of the false-positive method-call class described for PHP in #606 and fixed for Perl in #476. It is separate from #1271: that issue concerns collapsing a genuine in-graph polymorphic target set to one override, while this issue concerns fabricating a target that is not valid at all.
Reproduction
Public source
Repository and commit:
- https://github.com/Enferlain/sd-scripts/tree/de2dd0ebae40174e8336157e8928e36cfd013284
- Call sites: https://github.com/Enferlain/sd-scripts/blob/de2dd0ebae40174e8336157e8928e36cfd013284/library/training/phases/training_loop.py#L474-L545
- Unrelated test mock selected for
accelerator.print: https://github.com/Enferlain/sd-scripts/blob/de2dd0ebae40174e8336157e8928e36cfd013284/tests/unit/test_resume_logic.py#L19-L38 - Unrelated
backwardimplementation: https://github.com/Enferlain/sd-scripts/blob/de2dd0ebae40174e8336157e8928e36cfd013284/library/models/sdxl/unet.py#L52-L155 - Arbitrarily selected scheduler implementation: https://github.com/Enferlain/sd-scripts/blob/de2dd0ebae40174e8336157e8928e36cfd013284/library/pipelines/gradual_latent.py#L103-L150
Relevant source:
accelerator.print(...)
# ...
accelerator.backward(modifier_output.loss)
# ...
trainer.optimizer.step()
trainer.lr_scheduler.step()
trainer.optimizer.zero_grad(set_to_none=True)Run a full index, then inspect the direct call edges:
{
"project": "home-imi-Projects-sd-scripts",
"query": "MATCH (a:Function)-[r:CALLS]->(b:Method) WHERE a.qualified_name = 'home-imi-Projects-sd-scripts.library.training.phases.training_loop._run_epoch_steps' RETURN b.qualified_name, r.line, r.callee, r.strategy, r.confidence, r.candidates ORDER BY r.line"
}Relevant rows include:
line=482 callee=accelerator.print
-> tests.unit.test_resume_logic.MockAccelerator.print
strategy=field_type_hint confidence=0.85 candidates=2
line=532 callee=accelerator.backward
-> library.models.sdxl.unet.FlashAttentionFunction.backward
strategy=suffix_match confidence=0.28 candidates=2
line=541 callee=trainer.lr_scheduler.step
-> library.pipelines.gradual_latent.EulerAncestralDiscreteSchedulerGL.step
strategy=suffix_match confidence=0.01 candidates=84
There is also a compact repository-wide invariant demonstrating the false positives. Count production-library callers connected to test targets:
MATCH (caller:Function)-[r:CALLS]->(callee)
WHERE caller.file_path STARTS WITH 'library/'
AND callee.file_path STARTS WITH 'tests/'
RETURN count(r)Result: 26.
Repeat with (caller:Method):
MATCH (caller:Method)-[r:CALLS]->(callee)
WHERE caller.file_path STARTS WITH 'library/'
AND callee.file_path STARTS WITH 'tests/'
RETURN count(r)Result: 29.
The current index therefore contains 55 production-to-test CALLS edges. Production modules in this repository do not import or call the test suite, so these are false targets rather than merely low-confidence but possible calls.
The reproduced full index reported 12,131 nodes and 70,850 edges. check_index_coverage returned no_recorded_issue with matching generation metadata for every source path cited above.
Confirmed implementation behavior
Inspection of the resolver implementation matching this observed behavior found:
- Python attribute calls do not set
CBMCall.is_method; extraction currently sets it only for Perl and JavaScript/TypeScript/TSX member calls. - When Python LSP/type resolution misses, the generic registry resolves by the callee's simple name. For 2–256 same-name candidates it selects one candidate and still emits an ordinary
CALLSedge, with confidence reduced according to candidate count. try_field_type_hint()derives a type-like string by capitalizing the receiver name (accelerator->Accelerator) and selects the first candidate qualified name containing that string. It does not require exact receiver-type evidence or deprioritize test/mock classes, allowingMockAccelerator.printto receive confidence0.85.- The existing Python unknown-method test only asserts that any resolution has confidence below
0.6; it does not require the false target to be absent and does not verify the final graph edge. It also does not cover thefield_type_hintpath, which can raise a fabricated edge to high confidence.
Perl and TS/JS already have language-gated safeguards that suppress weak member-call strategies such as suffix_match, unique_name, and field_type_hint when receiver-aware resolution failed. Python currently cannot use an equivalent safeguard because its attribute calls are not marked as member calls.
Expected acceptance criteria
- An unresolved Python member call must not become an ordinary
CALLSedge to an unrelated same-named project method throughsuffix_match,unique_name,field_type_hint, or similar weak textual fallback. - Production callers must not resolve to methods defined only in test/mock classes without actual dependency/type evidence.
- LSP-, import-, same-module-, and otherwise receiver-aware genuine calls must remain supported.
field_type_hintshould require stronger receiver-type evidence and should not select test/mock candidates for production callers based only on a substring match.- Regression coverage should exercise the complete extraction-to-graph pipeline and assert final
CALLSedges, rather than only checking intermediate resolver confidence. - If unresolved calls are retained for diagnostics, their ambiguity should be explicit rather than represented as one concrete target.
Impact
These false edges directly corrupt caller/callee tracing and impact analysis. trace_path may report unrelated implementations as dependencies, and include_tests=false can hide a false production-to-test edge entirely, making the original call disappear instead of indicating that it was unresolved.
The practical workaround is to inspect raw edge metadata and distrust Python member-call edges produced by weak strategies, especially suffix_match with multiple candidates or field_type_hint without exact type evidence. This is difficult to apply through normal traversal output because trace_path does not surface those properties.
Logs
No runtime error is emitted. Indexing completes successfully; the problem is visible in the resulting graph.
Project scale
12,131 nodes / 70,850 edges / 801 indexed files
Confirmations
- I searched existing issues and did not find a Python report covering this failure.
- The reproduction uses shareable code from a public OSS repository.
Activity
DeusData commentedon Jul 28, 2026
Thanks for the repository-wide invariant and the final-edge acceptance criteria.
Current main confirms the asymmetry. The weak-match suppression helpers cover Perl and TS/JS member calls (src/pipeline/registry.c:403-455), while Python attribute calls can still reach resolve_multi_with_imports, which chooses one candidate and emits suffix_match even when no import-reachable target exists (registry.c:695-720). That makes the production-to-test edges structurally possible exactly as reported.
I have routed this silent graph-corruption bug to 0.9.1-rc at priority/high. Thank you for quantifying the impact instead of relying on one anecdotal edge.
test(parallel): record the weak-member trade for the LSP-ambiguity probe
fix(pipeline): suppress weak Python member calls (distilled from Deus…
fix(python): suppress bare calls shadowed by an enclosing parameter
fix(scala): suppress weak short-name matches for receiver calls
fix(scala): suppress weak short-name matches for receiver calls
fix(scala): suppress weak short-name matches for receiver calls
fix(scala): suppress weak short-name matches for receiver calls