feat(python): extract dataclass field references
What does this MR do and why?
Extracts references to instance fields in Python code.
This MR adds the reference extraction side for Python dataclass field accesses (e.g., instance.field). It introduces an attribute reference rule to the Python DSL configuration that correctly extracts the field name and maps its receiver chain, allowing the system to answer queries like "who reads User.email?".
Related Issues
Relates to #759 (closed) Blocked by #702 (closed)
Testing
Added the python_dataclass_references integration test fixture asserting the creation of a DefinitionToDefinition edge between a caller function and a target dataclass field. Verified locally via mise exec -- cargo nextest run -p integration-tests-codegraph --test suites python_dataclass_references.
(Note: As expected, the integration test currently fails to return rows because the target field definitions do not yet exist in the code graph. The tests should be green after #702 (closed) gets merged into main.)
Performance Analysis
This merge request does not introduce any performance regression. The addition of the attribute reference rule operates locally within the Python DSL and adds negligible overhead to AST traversal during extraction.
- This merge request does not introduce any performance regression. If a performance regression is expected, explain why.
Agent context — long-form analysis, file-by-file walkthroughs, profiler output, alternatives considered
crates/code-graph/src/v2/langs/generic/python.rs: Added a newreference("attribute")rule. Added.when(!parent_is("call"))condition to ensure this rule doesn't conflict with or double-extract method calls, which are already fully handled by the existingreference("call")rule.crates/integration-tests-codegraph/fixtures/python/dataclass_references.yaml:Created the integration test fixture mapping a dataclassUserwith anemail: strfield and asserting an edge to it from a consumer function.crates/integration-tests-codegraph/tests/suites.rs:Registered the new test fixture.