Commit graph

6801 commits

Author SHA1 Message Date
Kevin Turcios
881b4e9b35 fix: resolve merge conflicts and fix test failures
- Fix MockTestConfig missing tests_project_rootdir field
- Fix Python line profiler existence check on wrong path (no .lprof suffix)
- Add --release 11 to javac in Java line profiler tests for JDK compat
- Resolve merge conflicts with omni-java (replacement, tests)
- Add replace_function_definitions method to JavaSupport
- Guard against wrong method names in optimized code (standalone + class)
- Add tests for anonymous inner class method hoisting
2026-03-02 19:48:06 -05:00
Kevin Turcios
dc25d12e3c one more 2026-03-02 19:38:11 -05:00
Kevin Turcios
7b7c4fb385 Update parse_line_profile_test_output.py 2026-03-02 19:25:55 -05:00
Kevin Turcios
fe3e2f60c0 11 as per workflow 2026-03-02 19:25:30 -05:00
Kevin Turcios
f79cd9342a release 2026-03-02 19:20:44 -05:00
Kevin Turcios
626be4d337 use the class parser directly 2026-03-02 19:00:42 -05:00
Kevin Turcios
22b5f02d97 format 2026-03-02 18:48:33 -05:00
Kevin Turcios
d38a0b5493 temp 2026-03-02 18:47:32 -05:00
Saurabh Misra
1c0fe48741
Merge pull request #1704 from codeflash-ai/fix/java/wrong-method-name-replacement
fix: guard Java replacement against wrong-method-name candidates and anonymous-class method hoisting
2026-03-02 15:45:28 -08:00
misrasaurabh1
cd02dec79f test: use full string equality in anonymous iterator test
Replace substring-based assertions with a single exact string
comparison in test_anonymous_iterator_methods_not_hoisted_to_class,
matching the convention used elsewhere in the test file.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-02 23:38:42 +00:00
Kevin Turcios
e1f8e0710c refactor: make parse_test_xml a protocol method on LanguageSupport
Each language now owns its JUnit XML parsing instead of the shared
function branching on language checks and uses_compact_timing_markers.
2026-03-02 18:37:58 -05:00
Kevin Turcios
ea82e2cd46 refactor: delete dead concolic_testing.py from shared code
The concolic test generation logic was already moved into
PythonSupport.generate_concolic_tests. No callers remain.
2026-03-02 18:17:11 -05:00
Kevin Turcios
253ced9425 refactor: remove all is_java() guards from shared code
Replace with protocol dispatch via current_language_support():
- create_pr.py: use default_file_extension for path resolution
- verification_utils.py: use default_file_extension/get_test_file_suffix
- parse_test_output.py: compute uses_java_timing_markers once from extension
- instrument_existing_tests.py: remove dead Java branch (already dispatched
  via JavaSupport.instrument_existing_test)
2026-03-02 17:43:02 -05:00
Kevin Turcios
e67cdb952e fix paths 2026-03-02 17:33:11 -05:00
Kevin Turcios
66f1633ec8 fix: respect CODEFLASH_INNER_ITERATIONS env var in Java test runner
The Java test runner was overwriting the env var with the parameter default
(10), ignoring the value set by the test. Now only sets it if not already
present in the env.
2026-03-02 17:16:25 -05:00
Kevin Turcios
399441edd2 one more 2026-03-02 17:08:41 -05:00
Kevin Turcios
130953aab1 one more 2026-03-02 17:00:16 -05:00
Kevin Turcios
2a2b42194e fix: resolve remaining Java test failures
- Fix language detection in code_replacer to use lang_support.language
  (was None when function_to_optimize absent, blocking Java class member insertion)
- Update discover_functions calls in test_integration.py to pass source param
- Remove inner_iterations kwarg from test_run_and_parse.py (handled internally)
2026-03-02 16:33:53 -05:00
Kevin Turcios
67b422ffd3 fix: add @property to JavaSupport.function_optimizer_class, prek format fixes 2026-03-02 16:24:10 -05:00
Kevin Turcios
5b17da8f3d Update support.py 2026-03-02 16:16:23 -05:00
Kevin Turcios
754727c8f2 fix: resolve e2e failures (path, pass_fail_only, Java context, codeflash.toml)
- Use os.path.relpath for main.py path in e2e tests
- Remove pass_fail_only kwarg from JS/Java function optimizers
- Fix Java e2e test to use JavaFunctionOptimizer for code context
- Detect codeflash.toml in e2e test runner (not just pyproject.toml)
2026-03-02 16:08:21 -05:00
Kevin Turcios
61bcc37449 Update test_java_e2e.py 2026-03-02 16:04:03 -05:00
Kevin Turcios
83831ac25e fix: resolve e2e test path and pass_fail_only issues
- Use os.path.relpath for main.py path (works for any cwd depth)
- Remove pass_fail_only kwarg from JS/Java compare_test_results fallback
  (main removed this parameter from equivalence.compare_test_results)
2026-03-02 16:01:46 -05:00
claude[bot]
d5c744a9a4 style: auto-fix ruff formatting in java test_runner 2026-03-02 20:57:06 +00:00
Kevin Turcios
db447d6ba6 fix: pass test_string to instrument_existing_test in function_optimizer
The protocol signature changed to require test_string as first arg,
but the call site in instrument_existing_tests() wasn't updated.
2026-03-02 15:54:22 -05:00
Kevin Turcios
f7fd593de3 fix: resolve remaining test failures after main sync
- Fix min/max_outer_loops → pytest_min/max_loops in Java test_run_and_parse
- Update test_replacement.py for new replace_function_definitions_for_language API
- Update JavaSupport.discover_functions signature to match protocol
- Migrate _get_java_sources_root/_fix_java_test_paths to JavaFunctionOptimizer
- Fix test_java_tests_project_rootdir to use set_current_language
2026-03-02 15:47:23 -05:00
Kevin Turcios
e7687f2448 fix: rename min/max_outer_loops to pytest_min/max_loops and add Java cleanup patterns
Omni-java tests used renamed params that don't match main's API.
Also adds Java instrumented file patterns to leftover cleanup regex.
2026-03-02 15:40:26 -05:00
Kevin Turcios
a14bd09fdc fix: update Java tests for protocol-dispatch refactoring
Updates canary test to check JavaFunctionOptimizer instead of base
function_optimizer (comparison logic moved to subclass). Renames
min/max_outer_loops back to pytest_min/max_loops to match main's API.
2026-03-02 15:36:40 -05:00
Kevin Turcios
f37b37209c fix: update Java test_replacement import for moved code_replacer module 2026-03-02 15:32:57 -05:00
Kevin Turcios
2dfa74da84 chore: sync pyproject.toml from main and add tree-sitter-java dependency
Takes main's pyproject.toml and adds tree-sitter-java for Java language
support. Regenerates uv.lock.
2026-03-02 15:31:48 -05:00
Kevin Turcios
bd3ec8f09d test: sync dual-changed test files from main with omni-java fixes
Updates inject_profiling_into_existing_test calls to include test_string
parameter. Takes main's test refactoring for multi-file code replacement
and codeflash capture.
2026-03-02 15:30:16 -05:00
Kevin Turcios
19bd6e4bad test: sync test files from main (safe, main-only changes)
34 test files updated with main's refactored tests for new language
support protocol, JS/TS improvements, and code context extraction.
2026-03-02 15:25:50 -05:00
Kevin Turcios
2299d26ae5 feat: sync CLI from main with Java additions
Adds subagent mode, config display, and main's CLI refactoring.
Preserves omni-java's NullHighlighter, Java test root detection,
and Java project root detection (pom.xml/build.gradle).
2026-03-02 15:24:33 -05:00
Kevin Turcios
d518ad2d91 feat: sync core pipeline from main with Java protocol additions
Pulls refactored function_optimizer (language-agnostic via protocol),
optimizer, verification, aiservice, and models from main. Adds Java
protocol methods (process_generated_test_strings, default_language_version,
valid_test_frameworks, test_result_serialization_format), Java test file
path handling, and TestConfig.tests_root resolution.
2026-03-02 15:19:34 -05:00
Kevin Turcios
e222e248de feat: sync code utilities and discovery from main with Java additions
Pulls config_consts (token limit errors), time_utils (format_runtime_comment),
functions_to_optimize refactor, and discover_unit_tests protocol dispatch
from main. Adds Java adjust_test_config_for_discovery and lru_cache for
humanize_runtime.
2026-03-02 15:12:37 -05:00
Kevin Turcios
8046fcf461 feat: sync Python language changes from main with Java additions
Adds Python function optimizer subclass, normalizer, code context extractor
refactor, and code_replacer refactoring from main. Preserves omni-java's
instrument_existing_test signature, Java-specific code replacement logic,
filename-based fallback matching, and type skeleton testgen support.
2026-03-02 15:09:04 -05:00
Kevin Turcios
c37fb447e2 feat: sync language infrastructure from main with Java additions
Merges main's protocol additions (function_optimizer_class, prepare_module,
coverage, concolic tests, etc.) with omni-java's Java-specific additions
(FunctionFilterCriteria regex, instrument_existing_test signature,
inner_iterations, framework aliases).
2026-03-02 15:01:08 -05:00
Kevin Turcios
65288d1e51 feat: sync JS/TS language improvements from main
Adds mocha support, jest-reporter, JS function optimizer subclass,
code_replacer module, normalizer, and various JS support refinements.
Preserves omni-java's instrument_existing_test signature change.
2026-03-02 14:58:11 -05:00
Kevin Turcios
a538722ff7 chore: sync docs, CI, config, and rules from main
Pulls latest changes for .claude/rules/, .github/workflows/, CLAUDE.md,
and docs/ — all main-only changes with no omni-java overlap.
2026-03-02 14:56:26 -05:00
Kevin Turcios
ade70d6240 feat: sketch JavaFunctionOptimizer subclass
Follows the JavaScriptFunctionOptimizer pattern — handles Java-specific
code context building, candidate comparison via SQLite/Comparator JAR,
line profiling delegation, and code replacement.
2026-03-02 14:55:57 -05:00
claude[bot]
7dd25a08dd style: auto-fix ruff formatting issues 2026-03-02 03:37:52 +00:00
misrasaurabh1
2371540386 fix: guard Java replacement against wrong-method-name candidates and anonymous-class method hoisting
Two bugs in _parse_optimization_source (replacement.py) caused Maven compilation
failures when codeflash optimised aerospike-client-java:

Bug 1 – standalone method with wrong name replaces target
When the LLM generated a standalone method whose name did not match the
optimisation target (e.g. generated `unpackMap` for target `unpackObjectMap`,
or generated `sizeTxn` for target `estimateKeySize`), the function fell back to
using the entire generated snippet as `target_method_source`.  This silently
replaced the target with the wrong method, producing:
  • a duplicate definition of the wrong method
  • removal of the target method (breaking all callers)

Fix: after parsing standalone (class-free) code, verify that at least one
discovered method matches the target name.  If no match is found, set
`target_method_source` to the empty string and log a warning.  A corresponding
guard in `replace_function` returns the original source unchanged when
`target_method_source` is empty.

The same guard is applied to the full-class path: if the generated class does
not contain the target method, the candidate is also rejected.

Bug 2 – anonymous inner-class methods hoisted as top-level helpers
When an optimised method returned an anonymous class (e.g. `keySetIterator`
returning `new Iterator<LuaValue>() { … }`), tree-sitter's recursive walk
found the anonymous class's `hasNext`, `next`, and `remove` method_declaration
nodes and classified them as helpers to be inserted at the outer-class level.
The inserted methods carried `@Override` annotations that matched nothing in the
outer class and referenced local variables (`it`) that were only in scope inside
the optimised method body, producing compilation errors.

Fix: when extracting helpers from the optimised class, skip any method whose
line range is entirely contained within the target method's line range.  Such
methods belong to anonymous/nested classes inside the method body and must not
be hoisted out as standalone class members.

Tests added for both bugs in TestWrongMethodNameGeneration and
TestAnonymousInnerClassMethods.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-02 03:35:42 +00:00
Saurabh Misra
24e26c3944
Merge pull request #1698 from codeflash-ai/fix-runtime-calculation
fix runtime calculation for java
2026-03-01 02:32:15 -08:00
misrasaurabh1
d9de2cf459 add the jar back again 2026-03-01 02:24:15 -08:00
misrasaurabh1
1bcca07df3 revert 2026-03-01 02:11:16 -08:00
misrasaurabh1
4ecb6260fc fix: Java comparator key collision and add A/A baseline test
The Java Comparator used only iteration_id as the map key when comparing
test results. Since every test method had iteration_id="1", all rows
collapsed to a single entry and only the last row survived. Because JUnit
test execution order is non-deterministic, the surviving row differed
between baseline and candidate runs, causing false correctness failures.

Fix the key to include test_module_path:test_class_name:test_function_name
for unique identification. Also add an A/A test that runs the original code
through the candidate pipeline to detect verification bugs like this.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 02:05:07 -08:00
misrasaurabh1
00a5dc7712 remove logging statements 2026-02-28 23:47:40 -08:00
misrasaurabh1
e1fb4b81e8 fix runtime calculation for java 2026-02-28 21:35:45 -08:00
HeshamHM28
04b0dbdaf5
Merge pull request #1674 from codeflash-ai/fix/java/pr-test-path-resolution
fix: resolve Java test paths with .java extension in PR results
2026-02-25 20:56:19 -08:00
HeshamHM28
23db0d75b8 fix: add Java support for test module path resolution in existing_tests_source_for 2026-02-26 06:39:06 +02:00