Repository navigation
fix(rust): wire rust into class_start named-entity extraction (#1295) - #1373
Merged
Merged
Conversation
No language_standards.py regex change needed. Two ground-truth-side fixes:
- NODE_MAPS["rust"]["class_node_types"] was missing union_item (tree-sitter's
node type for `union Foo {...}`), a real class-like entity rust's own
class_start regex already matches. Adding it: real_classes/found_classes
242->245.
- The remaining extra_classes (11->25 after the union fix) all trace to
struct/enum/trait declarations sitting inside a macro invocation or
macro_rules!/proc-macro-template body (cfg_not_rt!, pin_project!,
ast_struct!, serde's $typaram-templated visitors) -- tree-sitter can't see
into opaque macro bodies, GitGalaxy's raw-text regex can. Same accepted
blind spot already documented for #1311/#1319's extra_functions, now
confirmed to apply identically to classes. Baseline hand-blessed to the
measured extra_classes=25, same precedent as csharp/zig.
crucible_check.py both modes clean, full core_engine/extraction suite passes
(6585 tests), audit_check.py clean.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extends #1264's per-language
class_startnamed-entity extraction to rust, per epic #1295. Nolanguage_standards.pyregex change needed -- two ground-truth-side fixes intests/tools/tree_sitter_accuracy_audit.py:NODE_MAPS["rust"]["class_node_types"]was missingunion_item(tree-sitter-rust's node type forunion Foo {...}, distinct fromstruct_item/enum_item) -- a real, named class-like entity rust's ownclass_startregex already matches (its comment covers struct/enum/union/trait). Confirmed via wasmtime'sFRegUnion/VRegUnion/XRegUnion, plain top-level unions with no macro involvement. Adding it:real_classes/found_classes242→245.extra_classes(11→25 after the union fix, usingtests/tools/class_start_diff.py --lang rust) all traced to struct/enum/trait declarations sitting inside a macro invocation ormacro_rules!/proc-macro-template body --cfg_not_rt! { pub(crate) struct JoinHandle<R> {...} },pin_project! { pub enum MaybeDone<Fut: Future> {...} },ast_struct! { pub struct Variant {...} }, serde's$typaram-templated visitor structs. Tree-sitter treats macro bodies as opaque token trees it can't parse into real declaration nodes, soreal_classescan never see these, while GitGalaxy's regex (raw text, no macro-awareness) matches them fine. This is the same blind spot already documented for rust/swift func_start extra_functions rose after #1302's prism.py fix -- newly exposed, not caused #1311/rust func_start misses bodyless multi-line trait method signatures (deserialize_* family) #1319'sextra_functionson rust -- now confirmed to apply identically toextra_classes. Not fixable without real macro expansion; documented as recurring-cause class 8 in the epic's checklist doc.found_classes165→245 (was low because rust has noclasskeyword, so the legacy fallback regex -- which only matchesclass|struct|interface|trait|enum-- structurally couldn't see most rust declarations). Baseline hand-blessed to the measuredextra_classes=25, same precedent as csharp (#1264) and zig (#1367): a confirmed, understood, non-bug gap, not an unexplained regression.Verification
python tests/tools/tree_sitter_accuracy_audit.py --lang rust --ci-- clean against hand-blessed baselinepython tests/tools/crucible_check.py-- both modes (full_precision, zero_dependency) PASSpython tests/tools/audit_check.py --regenerate-- ruff findings were pure line-shifts, baseline regeneratedpython -m pytest tests/core_engine/ tests/extraction/-- 6585 passed, 2 skipped, 11 xfailed, 3 xpassedTest plan
tree_sitter_accuracy_audit.py --lang rust --cicleancrucible_check.pyboth modes cleanaudit_check.pycleancore_engine/extractionsuite passes🤖 Generated with Claude Code