Skip to content

fix(rust): wire rust into class_start named-entity extraction (#1295) - #1373

Merged
squid-protocol merged 1 commit into
mainfrom
fix/rust-class-start-named-extraction-1295
Aug 12, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
fix/rust-class-start-named-extraction-1295

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

Extends #1264's per-language class_start named-entity extraction to rust, per epic #1295. No language_standards.py regex change needed -- two ground-truth-side fixes in tests/tools/tree_sitter_accuracy_audit.py:

  1. NODE_MAPS["rust"]["class_node_types"] was missing union_item (tree-sitter-rust's node type for union Foo {...}, distinct from struct_item/enum_item) -- a real, named class-like entity rust's own class_start regex already matches (its comment covers struct/enum/union/trait). Confirmed via wasmtime's FRegUnion/VRegUnion/XRegUnion, plain top-level unions with no macro involvement. Adding it: real_classes/found_classes 242→245.
  2. The remaining extra_classes (11→25 after the union fix, using tests/tools/class_start_diff.py --lang rust) all traced to struct/enum/trait declarations sitting inside a macro invocation or macro_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, so real_classes can 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's extra_functions on rust -- now confirmed to apply identically to extra_classes. Not fixable without real macro expansion; documented as recurring-cause class 8 in the epic's checklist doc.

found_classes 165→245 (was low because rust has no class keyword, so the legacy fallback regex -- which only matches class|struct|interface|trait|enum -- structurally couldn't see most rust declarations). Baseline hand-blessed to the measured extra_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 baseline
  • python tests/tools/crucible_check.py -- both modes (full_precision, zero_dependency) PASS
  • python tests/tools/audit_check.py --regenerate -- ruff findings were pure line-shifts, baseline regenerated
  • python -m pytest tests/core_engine/ tests/extraction/ -- 6585 passed, 2 skipped, 11 xfailed, 3 xpassed

Test plan

  • tree_sitter_accuracy_audit.py --lang rust --ci clean
  • crucible_check.py both modes clean
  • audit_check.py clean
  • Full core_engine/extraction suite passes

🤖 Generated with Claude Code

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>
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit b9c0ec1 into main Aug 12, 2026
30 checks passed
@squid-protocol
squid-protocol deleted the fix/rust-class-start-named-extraction-1295 branch August 12, 2026 19:59
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