Skip to content

Conversation

@john-b-yang
Copy link
Member

@john-b-yang john-b-yang commented Jul 28, 2025

Add Procedural Modification techniques for Rust

The original SWE-smith work introduces a line of "Procedural Modification" techniques, where programmatic entities are converted into an AST. The AST is then randomly manipulated (e.g. changing an operator, inverting a condition, removing a condition), and the resulting AST is converted back into code to serve as a bug.

Procedural Modifications currently work for both Python and Golang. This is a WIP PR to make it work for Rust.

Typically, the steps to implement procedural modifications are as follows:

  1. Ensure that swesmith/bug_gen/adapters/<language>.py has the _analyze_properties function implemented. This function is what will take each CodeEntity and assign to it one or more CodeProperty tags.
  2. Implemented procedural modifications under swesmith/bug_gen/procedural/<language>/. You can see a number of existing examples for how this works. Each PM, defined as a class, takes in a CodeEntity and produces a BugRewrite object.
  3. In swesmith/bug_gen/procedural/<language>/__init__.py, create a MODIFIERS_<LANG> variable which points at a list of procedural modification classes. Then add the extension -> MODIFIERS_<LANG> map to MAP_EXT_TO_MODIFIERS.
  4. Add tests as needed.

For this PR, the following have been implemented:

  • Step 1
  • Step 2
  • Step 3
  • Step 4

@john-b-yang john-b-yang added the help wanted Extra attention is needed label Jul 28, 2025
@codecov
Copy link

codecov bot commented Jul 28, 2025

Codecov Report

❌ Patch coverage is 95.26066% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
swesmith/bug_gen/adapters/rust.py 91.42% 9 Missing ⚠️
tests/conftest.py 80.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
swesmith/constants.py 94.78% <100.00%> (+0.04%) ⬆️
tests/bug_gen/adapters/test_rust.py 100.00% <100.00%> (ø)
...ts/bug_gen/procedural/golang/test_go_operations.py 100.00% <ø> (ø)
tests/bug_gen/procedural/golang/test_go_remove.py 100.00% <ø> (ø)
tests/conftest.py 95.31% <80.00%> (-1.41%) ⬇️
swesmith/bug_gen/adapters/rust.py 93.88% <91.42%> (-3.52%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

help wanted Extra attention is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants