refactor: prepare omni-java for main merge (batch 2)#1717
refactor: prepare omni-java for main merge (batch 2)#1717
Conversation
Remove safe_relative_to, resolve_classes_from_modules, extract_classes_from_type_hint, resolve_transitive_type_deps, extract_init_stub, _is_project_module_cached, is_project_path, _is_project_module, extract_imports_for_class, collect_names_from_annotation, is_dunder_method, _qualified_name, and _validate_classdef. Inline trivial helpers into prune_cst and clean up enrich_testgen_context and get_function_sources_from_jedi. Remove corresponding tests.
Add enrichment step that parses FTO parameter type annotations, resolves types via jedi (following re-exports), and extracts full __init__ source to give the LLM constructor context for typed parameters.
Fix 10 failing tests: remove wrong assertions expecting import statements inside extracted class code, use substring matching for UserDict class signature, and rewrite click-dependent tests as project-local equivalents. Add tests for resolve_instance_class_name, enhanced extract_init_stub_from_class, and enrich_testgen_context instance resolution.
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
The optimized code achieves a **70% runtime speedup** (from 7.02ms to 4.13ms) through three key improvements: ## 1. **Faster Class Discovery via Deque-Based BFS (Primary Speedup)** The original code uses `ast.walk()` which recursively traverses the entire AST tree even after finding the target class. The line profiler shows this taking 20.5ms (71% of time). The optimized version replaces this with an explicit BFS using `collections.deque`, which stops immediately upon finding the target class. The profiler shows this reduces traversal time to 9.95ms - **cutting the search overhead by >50%**. This is especially impactful when: - The target class appears early in the module (eliminates unnecessary traversal) - The module contains many classes (test shows 7-10% faster on modules with 100-1000 classes) - The function is called frequently (shown by the 108% speedup on 1000 repeated calls) ## 2. **Explicit Loops Replace Generator Overhead** The original code uses `any()` with a generator expression and `min()` with a generator to check decorators and find minimum line numbers. These create function call and generator overhead. The optimized version uses explicit `for` loops with early breaks: - Decorator checking: Directly iterates and breaks on first match - Min line number: Uses explicit comparison instead of `min()` generator The profiler shows decorator processing time reduced from ~1.4ms to ~0.3ms, and min line calculation from 69μs to 28μs. ## 3. **Conditional Flag Pattern for Relevance Checking** Instead of evaluating both conditions in a compound expression, the optimized version uses an `is_relevant` flag with early exits, reducing redundant checks. ## Impact on Workloads Based on `function_references`, this function is called from: - `enrich_testgen_context`: Used in test generation workflows where it may process many classes - Benchmark tests: Indicates this is in a performance-critical path The optimization particularly benefits: - **Large codebases**: 89-90% faster on classes with 100+ methods or 50+ properties - **Repeated calls**: 108% faster when called 1000 times in sequence - **Early matches**: Up to 88% faster when target class is found quickly - **Deep nesting**: 57% faster for nested classes The annotated tests show consistent 50-108% speedups across most scenarios, with minimal gains (6-10%) only when processing very large files where string slicing dominates runtime.
…2026-02-18T14.38.26
Add --agent CLI flag for AI agent integrations that skips all interactive prompts. In agent mode, checkpoint resume is skipped entirely so each run starts fresh. Also gates the existing checkpoint prompt behind --yes.
In agent mode, disable all Rich output (panels, spinners, progress bars, syntax highlighting) and use a plain StreamHandler for logging. Optimization results with explanation and unified diff are written to stdout. A log filter strips LSP prefixes and drops noisy test/file-path messages. Also skip checkpoint creation and suppress Python warnings in agent mode.
…oncolic tests - --agent now implies --no-pr and --worktree so source files stay clean - Output uses structured XML (codeflash-optimization) with optimized-code for the consuming agent to apply via Edit/Write - Skip concolic test generation in agent mode - Skip patch file creation in worktree + agent mode
fix: resolve test file paths in discover_tests_pytest to fix path com…
The comparator did not recognize `types.UnionType` (Python 3.10+ `X | Y` syntax), causing it to fall through to "Unknown comparator input type". Conditionally include it in the equality-checked types tuple. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Rename the CLI flag, env var (CODEFLASH_SUBAGENT_MODE), helper (is_subagent_mode), and related symbols to avoid confusion with CodeFlash's own agent terminology.
Avoids computing the full summary (callee counts, string formatting) only to discard it when running in subagent mode.
…owing - Use XML structure instead of markdown for clearer step boundaries - Resolve stale review threads via GraphQL instead of leaving them - Positive framing instead of negation for instructions - Replace aggressive language with calm direct instructions - Add /simplify skill invocation for code quality pass - Add verification checkpoint at the end - Auto-close stale codeflash optimization PRs (age, conflicts, CI failures, deleted functions) - Remove inline comment MCP tool, add Skill tool
fix: rewrite Claude Code PR review prompt
|
⚡️ Codeflash found optimizations for this PR📄 14% (0.14x) speedup for
|
56ae338 to
7f96d61
Compare
Full Java optimization pipeline: discovery, test discovery, context extraction, instrumentation, test execution (Maven/direct JVM), benchmarking, code replacement, coverage (JaCoCo), line profiling, and result comparison (Kryo serialization). Includes protocol-aligned JavaSupport, JavaFunctionOptimizer, and merge fixes for omni-java → main integration.
7f96d61 to
7b8169d
Compare
Summary
is_java()guards intactChanges
verifier.py— remove inline JS instrumentation and module detectiontest_runner.py— remove test runner functions (moved to language support)code_context_extractor.py— removeget_code_optimization_context_for_languagecode_replacer.py— removereplace_function_definitions_for_languageand helpersoptimizer.py— remove JS methods, replace inline Python/JS logic with protocol dispatchtest_multi_file_code_replacement.py— update toPythonFunctionOptimizerStill remaining
function_optimizer.py— base class extraction (the big one)