-
Notifications
You must be signed in to change notification settings - Fork 22
CC Augmented optimizations #1104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
KRRT7
wants to merge
11
commits into
main
Choose a base branch
from
augmented-optimizations
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
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
When LLM-generated optimizations use module-level code that depends on functions defined later in the original file (e.g., `_TABLE = func(...)`), the assignments were being inserted after imports but before the function definitions, causing NameError at import time. This fix: - Adds NameCollector visitor to extract names from assignment values - Tracks positions of function/class definitions in the module - Inserts each assignment after all its dependencies are defined - Assignments without dependencies still go after imports Fixes optimization failures for functions like `standardize_quotes` that use helper functions like `unicode_to_char` defined later in the file.
…ization results Adds a new `codeflash create-pr` subcommand that creates PRs from previously applied optimizations stored in a JSON results file. This enables a two-phase workflow where optimizations are applied locally first, then PRs can be created separately.
…n add_global_assignments Previously, GlobalStatementCollector only collected SimpleStatementLine nodes, causing module-level for-loops (and other compound statements) to be dropped. This caused NameError for loop variables like 'uval', 'unicode_val', 'ch' when LLM-generated optimizations used for-loops to build translation tables. - Add compound statement collection to GlobalStatementCollector - Update ImportInserter to handle both simple and compound statements - Add tests for all reported NameError cases
For-loops and other compound statements at module level may call functions defined later in the file. Previously, they were inserted after imports, causing NameError when the called function was defined after the for-loop. Now: - Simple statements (assignments) are inserted after imports - Compound statements (for/while/with/try) are inserted at the END of the module This fixes NameError cases like 'unicode_to_char is not defined' when LLM-generated optimizations use module-level for-loops to build translation tables that call helper functions.
When LLM-generated optimizations introduce new helper functions that are called at module level, these functions must be transferred to the original code. Added FunctionDefCollector, FunctionNameCollector, and FunctionDefInserter to detect and transfer new function definitions before assignments that depend on them.
Capture test report summary and loop count during phase1 optimization so the create-pr CLI can generate PR comments without re-running tests.
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.
No description provided.