Skip to content

Fix #819: Extraction hardening for rust - #874

Merged
squid-protocol merged 1 commit into
mainfrom
feature/819-extraction-hardening-rust
Jul 31, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
feature/819-extraction-hardening-rust

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

Part of the extraction-hardening epic (#813). Closes #819.

Hardens all four extraction gauntlets (func_start, args, class_start, _dependency_capture) for rust per tests/extraction/how_to_harden_extraction.md. This was a fresh sweep (no pre-flagged known bug) and surfaced two real bugs:

  • args' generic-parameter step-over was still the flat <[^>]*>, unlike func_start's own two-level-nesting Rule-11 idiom fixed in an earlier pass. Broke on any nested trait bound (fn foo<T: Into<String>>(x: T) {, a realistic, common Rust pattern — any generic function bounded by a From/Into conversion trait). Widened to match func_start's already-proven idiom. A prior partial fix on one rule doesn't mean a sibling rule parsing the identical shape got it too.
  • _dependency_capture's character class was missing *, so every glob import (use std::io::*;, use super::*; — extremely common, appears in nearly every Rust test submodule and in re-export-heavy crates) produced zero dependency-graph edges.

Also documents a known, unfixed architectural limitation (out of scope for a single-language pass, tracked in the epic): func_start/_dependency_capture's Mode-B string-shielding gap reproduces on Rust raw string literals (r#"..."#, common for embedded SQL/regex/JSON) — now confirmed on a fourth language/feature after js/ts template literals (#815), Java text blocks (#816), and Go raw strings (#817).

Differential Scan

Ran python tests/tools/crucible_check.py: 4 real corpus files across rust/holylang and rust/bevy gained newly-detected glob-import dependency edges (e.g. one file's detected-dependency count jumped 1 → 5). Manually confirmed every new edge is a genuine pub use x::*;/use x::*; re-export in the source, not a parsing artifact, and confirmed no other language/file is affected anywhere in the ~80-repo corpus. Golden masters re-blessed for this on-target, expected change via crucible_check.py --update --yes.

Test plan

  • pytest tests/extraction/languages/test_rust.py (51 new tests) — run via bare pytest from an unrelated CWD to reproduce CI's invocation style
  • pytest tests/core_engine/ tests/extraction/ -q — 3503 passed, 1 known pre-existing tiktoken-environment failure, 1 xfailed
  • python tests/tools/audit_check.py — clean (only the pre-existing, already-tracked guidestar_lens.py mypy findings, unrelated to this change)
  • python tests/tools/crucible_check.py — PASS on both venvs after re-blessing
  • Migrated rust's cases out of the four monolithic dict files into tests/extraction/languages/test_rust.py
  • Epic Epic: Harden the four extraction gauntlets (function/args/class/dependency) per language #813 and the methodology doc updated with the new findings (recurring bug classes 18-20)

🤖 Generated with Claude Code

Hardens all four extraction gauntlets for rust. This was a fresh sweep
(no pre-flagged known finding) and surfaced two real bugs:

- args' generic-parameter step-over was still the flat `<[^>]*>`, unlike
  func_start's own two-level-nesting Rule-11 idiom fixed in an earlier
  pass. Broke on any nested trait bound
  (`fn foo<T: Into<String>>(x: T) {`, a realistic, common Rust pattern --
  any generic function bounded by a From/Into conversion trait). Widened
  to match func_start's already-proven idiom. A prior partial fix on one
  rule doesn't mean sibling rules parsing the identical shape got it too.

- _dependency_capture's character class was missing `*`, so every glob
  import (`use std::io::*;`, `use super::*;` -- extremely common, appears
  in nearly every Rust test submodule and in re-export-heavy crates)
  produced zero dependency-graph edges.

Verified via crucible_check.py: 4 real corpus files across rust/holylang
and rust/bevy gained newly-detected glob-import dependency edges (e.g.
one file's detected-dependency count jumped 1 -> 5, all confirmed genuine
`pub use x::*;` re-exports, not parsing artifacts). Confirmed no other
language/file affected. Golden masters re-blessed for this on-target,
expected change.

Also documents a known, unfixed limitation: func_start/_dependency_capture's
Mode-B string-shielding gap reproduces on Rust raw string literals
(`r#"..."#`) -- now confirmed on a FOURTH language/feature after js/ts
template literals, Java text blocks, and Go raw strings.

Migrates rust's test cases out of the four monolithic dict files into
tests/extraction/languages/test_rust.py, and updates the epic +
methodology doc with the new findings (recurring bug classes 18-20).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@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 88cee50 into main Jul 31, 2026
27 checks passed
@squid-protocol
squid-protocol deleted the feature/819-extraction-hardening-rust branch July 31, 2026 02:45
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.

Extraction hardening: rust

1 participant