Commit graph

7995 commits

Author SHA1 Message Date
Kevin Turcios
07e4566271 ci: remove self-references from workflow path filters
Editing a workflow YAML file should not trigger that same workflow
to run. Removes .github/workflows/<file> from its own paths filter
in mypy.yml, prek.yaml, and unit-tests.yaml.
2026-04-09 05:08:19 -05:00
Kevin Turcios
e2e8557958 ci: remove self-reference from codeflash-optimize paths
Editing the workflow config shouldn't trigger a full optimization run.
2026-04-09 05:04:32 -05:00
Kevin Turcios
b38cfd2186 ci: scope workflow triggers to relevant paths
- codeflash-optimize.yaml: replace paths: ['**'] wildcard with targeted filters
- mypy.yml: add path filters (was firing on every PR/push including docs)
- prek.yaml: add path filters (was firing on every PR)
- unit-tests.yaml: add path filters (was firing on every PR/push)

Docs-only, README, experiment, and LICENSE changes no longer trigger
these workflows. Saves ~20 workflow runs per docs-only PR.
2026-04-09 04:59:24 -05:00
Kevin Turcios
56841683c3
Merge pull request #2036 from codeflash-ai/perf/defer-main-imports
perf: defer module-level imports in main.py into main()
2026-04-09 04:54:09 -05:00
Kevin Turcios
0bbe22288c
Merge pull request #2035 from codeflash-ai/perf/defer-telemetry-imports
perf: defer posthog, sentry_sdk, and requests imports in telemetry
2026-04-09 04:54:06 -05:00
Kevin Turcios
07bd44db28
perf: add --version fast-path to skip full import chain
perf: add --version fast-path to skip full import chain
2026-04-09 04:50:14 -05:00
Kevin Turcios
6f3f88498a perf: defer module-level imports in main.py into main()
Move cli, console, env_utils, checkpoint, config_parser, and
version_check imports from module level into main(). These imports
trigger the full dependency chain (cfapi, models, PrComment, libcst,
requests, Rich) costing ~500ms on every CLI invocation — even for
simple commands that dont need most of these modules.

Also moves paneled_text import into print_codeflash_banner() and
passes process_pyproject_config as parameter to _handle_config_loading
to avoid a module-level reference.
2026-04-09 09:40:07 +00:00
Kevin Turcios
fd7e2c01a2 perf: add --version fast-path to skip full import chain
When the user runs `codeflash --version`, read the version string
and exit immediately without importing cli, telemetry, models, or
any other heavy modules. This mirrors the pattern used in pip where
`pip --version` was optimized from 138ms to 20ms (7x).

Before: 524ms (imports cli.py -> cfapi -> models -> libcst -> ...)
After:  ~16ms (imports only codeflash.version)
2026-04-09 09:40:07 +00:00
Kevin Turcios
161ab34f3b
Merge pull request #2041 from codeflash-ai/ci/disable-dependabot
ci: temporarily disable Dependabot PRs
2026-04-09 04:38:43 -05:00
Kevin Turcios
9af6ce8064 ci: temporarily disable Dependabot PRs
Sets open-pull-requests-limit: 0 on all ecosystems. Existing open
Dependabot PRs are unaffected — this only prevents new ones.

Re-enable by removing the open-pull-requests-limit lines.
2026-04-09 04:38:12 -05:00
Kevin Turcios
d4876edefe
Merge pull request #2039 from codeflash-ai/ci/disable-pr-review
ci: temporarily disable automatic PR review job
2026-04-09 04:33:46 -05:00
Kevin Turcios
507319066a ci: temporarily disable automatic PR review job
Adds `false &&` guard to the pr-review job condition. The job will
be skipped on all triggers until this is reverted. The @claude mention
job is unaffected.
2026-04-09 04:33:11 -05:00
Kevin Turcios
2cd23f9191 perf: defer posthog, sentry_sdk, and requests imports in telemetry
Move heavy third-party imports (posthog, sentry_sdk, and their
integrations) from module level into the functions that use them.
These imports cost ~350ms combined but are only needed when
telemetry is actually initialized, not on every CLI invocation.

- posthog_cf.py: defer `from posthog import Posthog` into
  initialize_posthog(), defer cfapi/console/lsp imports into ph()
- sentry.py: defer `import sentry_sdk` and integrations into
  init_sentry()
2026-04-09 09:16:37 +00:00
HeshamHM28
f5777947c6 Merge remote-tracking branch 'origin/main' into cf-java-void-optimization 2026-04-09 08:15:53 +00:00
Kevin Turcios
9e6923916c
Merge pull request #2027 from codeflash-ai/fix/dependabot-exclude-fixtures
ci: exclude test fixtures from Dependabot
2026-04-09 02:51:20 -05:00
Kevin Turcios
50224baee9 ci: add dependabot.yml to exclude test fixture directories
Dependabot was auto-discovering all package.json and pyproject.toml
files including 12 in code_to_optimize/ (test fixtures). These PRs
always fail because E2E tests need secrets unavailable on Dependabot
PRs — 70% of Dependabot runs were failing on vite updates to fixtures.

Explicit config monitors only the real dependency files:
- / (root pyproject.toml)
- /packages/codeflash (npm package)
- GitHub Actions versions
2026-04-09 02:50:03 -05:00
Kevin Turcios
bd051ffb42
Merge pull request #2026 from codeflash-ai/fix/pin-claude-code-action-v1.0.89
ci: pin claude-code-action to v1.0.89 (fix Bedrock auth)
2026-04-09 02:17:16 -05:00
Kevin Turcios
77be8b1949
Merge pull request #2025 from codeflash-ai/fix/e2e-path-triggers
ci: replace wildcard path triggers on E2E tests
2026-04-09 02:17:01 -05:00
Kevin Turcios
3dc21bdec3 ci: pin claude-code-action to v1.0.89 to fix Bedrock auth
v1.0.90 broke Bedrock OIDC auth — all Claude Code runs have been
failing with 403 since Apr 8.

Root cause: anthropics/claude-code-action#1196
Pinning to v1.0.89 (last working version) until upstream fix lands.
2026-04-09 02:12:14 -05:00
Kevin Turcios
d344324325 ci: replace wildcard path triggers with targeted filters on E2E tests
All 12 E2E workflows used `paths: ['**']` which triggered on every file
change — docs, configs, experiments, etc. This caused ~140-200 min of
compute per push event (18+ parallel workflows).

Now E2E tests only trigger when relevant source code changes:
- Python E2E: codeflash/**, tests/**, pyproject.toml, uv.lock, workflow files
- JS E2E: same + packages/**
- Java E2E: already had proper path filters (no change needed)

Estimated savings: ~$150-200/mo in CI compute.
2026-04-09 02:06:28 -05:00
mashraf-222
1f698374e5
Merge pull request #2019 from codeflash-ai/cf-1090-java-documentation-gaps
docs: fix Java documentation gaps across 5 pages
2026-04-09 01:09:10 +02:00
Aseem Saxena
4392694ab5
Merge pull request #2021 from codeflash-ai/feat/track-subagent-mode-posthog
feat: track subagent mode in PostHog
2026-04-08 14:06:27 -07:00
Mohamed Ashraf
5f2a1c84de feat: track subagent mode globally in all PostHog events
Move subagent tracking from a single event property to the ph() function
so every PostHog event is automatically tagged with subagent: true/false.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 20:33:52 +00:00
Aseem Saxena
a958f3182b
Merge pull request #1856 from codeflash-ai/fix/structured-error-output-subagent-mode
fix: output structured XML errors in subagent mode
2026-04-08 12:48:18 -07:00
aseembits93
4a50528c49 feat: track subagent mode in cli-optimize-run-start PostHog event
Adds `subagent: bool` property to the existing run-start event so PostHog
can segment and compare agent-driven vs human CLI optimization runs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-08 12:29:49 -07:00
Mohamed Ashraf
29879f19bc Merge branch 'main' into cf-1085-cap-wildcard-import-expansion 2026-04-08 17:11:37 +00:00
Mohamed Ashraf
3b03249950 Merge remote-tracking branch 'origin/main' into cf-1087-field-injection-class-filter 2026-04-08 17:07:40 +00:00
Mohamed Ashraf
71fc73eec3 Merge remote-tracking branch 'origin/main' into cf-1090-java-documentation-gaps 2026-04-08 17:07:40 +00:00
mashraf-222
33c8cc19e4
Merge pull request #1946 from codeflash-ai/cf-1080-spotless-skip
fix: add Spotless skip flags to Maven and Gradle validation
2026-04-08 18:40:52 +02:00
Mohamed Ashraf
fdc7a52f33 Merge remote-tracking branch 'origin/main' into cf-1087-field-injection-class-filter 2026-04-08 16:39:23 +00:00
Mohamed Ashraf
81e665dde4 docs: fix Java documentation gaps across 5 pages
Add Java to supported languages in how-codeflash-works, add auth and
GitHub App steps to java-installation, add Java tab to codeflash-all
tip, reorder trace-and-optimize Java examples, and clarify Java class
method syntax in one-function.

Closes CF-1090

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 16:28:19 +00:00
Mohamed Ashraf
8961b14d6f fix: update test assertion to match POSIX-normalized paths in Jest config
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 12:12:26 +00:00
Mohamed Ashraf
4c70a21294 fix: resolve Windows CI failures from path separator mismatches
Normalize paths to forward slashes in JS/TS code generation and coverage
parsing — backslashes are escape chars in JavaScript strings and cause
silent corruption on Windows. Also relax timing test thresholds for CI.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-08 00:15:40 +00:00
Mohamed Ashraf
5e2ef37f6f fix: increase coverage timeout to 1200s for large Gradle --no-daemon builds
Gradle --no-daemon on multi-module projects forces a full JVM cold start
for every invocation. On eureka, configuration + dependency resolution
alone takes ~10 min before tests even start. 900s was still getting
killed at the boundary.

1200s (20 min) provides headroom for: cold Gradle startup (~10 min) +
test execution (~5 min) + JaCoCo overhead + safety margin.

PR #2013 iterated through 300→600→900s and found 900s sufficient only
when build caches were warm from prior invocations in the same session.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 16:13:06 +00:00
Mohamed Ashraf
389aa16f76 fix: pre-compile test classes and increase compilation timeout for Gradle
Two changes to prevent cold-build timeouts on large multi-module Gradle
projects (e.g., eureka ~16 min cold build):

1. install_multi_module_deps now compiles testClasses instead of just
   classes, so the test execution timeout only covers running tests,
   not compilation.

2. Pre-install compilation timeout increased from 300s to 900s to
   accommodate cold Gradle --no-daemon builds on large projects.

Combined with the coverage min_timeout of 900s (previous commit),
compilation and test execution each get their own 900s budget instead
of sharing one.

Ported from PR #2013 experience where 300s/600s were validated as
insufficient for eureka cold builds.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 15:55:00 +00:00
Mohamed Ashraf
e658fb45af fix: increase coverage timeout from 300s to 900s for Gradle builds
Gradle --no-daemon on multi-module projects (e.g., eureka) needs cold
JVM startup + dependency resolution + compilation + test execution +
JaCoCo agent overhead, which exceeds 300s. At 300s the process is
killed mid-execution, producing partial results that the pipeline
can't use for behavioral baseline.

Ported from PR #2013 which validated 300s→600s→900s progression on
eureka (build takes ~10 min, 900s provides safe headroom).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 15:35:55 +00:00
Mohamed Ashraf
217544f99e fix: handle multi-line include directives in settings.gradle
The regex for extracting modules from settings.gradle only matched
single-line include statements. Multi-line includes like eureka's
(include 'a',\n 'b',\n 'c') only captured the first module, causing
test_module to be None and breaking multi-module path resolution
(e.g., classfiles lookup for JaCoCo coverage conversion).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 15:03:32 +00:00
claude[bot]
2a2125be9c
Merge pull request #2017 from codeflash-ai/codeflash/optimize-pr2015-2026-04-07T11.40.43
️ Speed up function `_extract_modules_from_settings_gradle` by 23% in PR #2015 (`fix/gradle-maven-central-dependency`)
2026-04-07 14:58:28 +00:00
claude[bot]
ba8dd8bdb9 fix: add project_classpath param to base LanguageSupport.instrument_source_for_line_profiler 2026-04-07 14:56:15 +00:00
Mohamed Ashraf
1fa01a3296 fix: replace Gradle JaCoCo plugin with runtime JAR agent for coverage
The Gradle JaCoCo plugin approach (jacocoTestReport task) fails on
multi-module projects and adds 5-10 min overhead. Replace with:

1. Inject -javaagent:{runtime_jar}=destfile={exec} via JAVA_TOOL_OPTIONS
   (AgentDispatcher routes destfile= args to JaCoCo PreMain)
2. Run tests without jacocoTestReport task
3. Convert .exec to .xml via shaded JaCoCo CLI in the runtime JAR

This eliminates the "jacocoTestReport not found" error on eureka and
similar multi-module Gradle projects, and removes build file mutation
for coverage setup.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 14:50:45 +00:00
Mohamed Ashraf
32bbe57867 fix: add classpath hint to find_agent_jar for Gradle JAR resolution
Gradle resolves the codeflash-runtime JAR to ~/.gradle/caches/, not
~/.m2/. Add an optional classpath parameter to find_agent_jar() that
searches the resolved classpath for the JAR before falling back to
the existing ~/.m2 / resources / dev-build chain.

Thread the parameter through build_javaagent_arg, build_agent_env,
instrument_source_for_line_profiler, and line_profiler_step so the
optimization pipeline passes the resolved classpath automatically.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 14:49:03 +00:00
Mohamed Ashraf
0ab4800f74 fix: use tree-sitter for Gradle repositories block and add version update logic
- Generalize _find_top_level_dependencies_block() into _find_top_level_block(name)
  so it can find any top-level block (dependencies, repositories, etc.)
- Rewrite _ensure_maven_central_repo() to use tree-sitter instead of regex,
  preventing false matches inside buildscript/subprojects/allprojects blocks
- Add _update_existing_codeflash_dependency() to replace stale versions or
  old files() format with the current Maven Central coordinate
- Wire version update into add_codeflash_dependency() and
  add_codeflash_dependency_multimodule() so old entries get updated instead
  of silently skipped

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-07 14:46:37 +00:00
codeflash-ai[bot]
2e4df0a7fe
Optimize _extract_modules_from_settings_gradle
The optimization pre-compiles three regex patterns at module load time (`_INCLUDE_PATTERN`, `_LISTOF_PATTERN`, `_QUOTED_PATTERN`) instead of recompiling them on every function call, eliminating the ~1 ms pattern-compilation overhead that line profiler shows dominated the original version (44.3% of total time in the first `re.findall` alone). The second major change replaces the O(n) `if stripped not in modules` list scan with a set-based `if stripped not in seen` check, which cuts the deduplication cost from ~288 ns to ~72 ns per check when the fallback listOf branch executes. Runtime improves from 2.35 ms to 1.91 ms (23% faster) with no behavioral regressions.
2026-04-07 11:40:47 +00:00
HeshamHM28
1fde200bc4 fix: improve multi-module Gradle detection for dynamic settings.gradle.kts
- Parse listOf(...) patterns in settings.gradle.kts for projects that
  build include lists dynamically (e.g. OpenRewrite)
- Use word boundary in include regex to avoid matching variable names
  like 'includedProjects'
- Break module voting ties using codeflash.toml module-root config,
  so the function's own module is preferred over cross-module tests

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 11:08:16 +00:00
HeshamHM28
80581971a6 fix: add VOID_STATE to VerificationType enum
Instrumentation writes verification_type="void_state" for void methods,
but the enum lacked this value, causing ValueError on every SQLite row parse.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 08:28:21 +00:00
claude[bot]
8e2bab2e42 fix: add missing return type annotations to test functions
Co-authored-by: Aseem Saxena <aseembits93@users.noreply.github.com>
2026-04-06 23:12:44 +00:00
aseembits93
48e6835990 feat: use sys.argv[1:] for help check and add tests
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 16:09:47 -07:00
aseembits93
e3488bce6f feat: display logo when running codeflash --help
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 16:06:56 -07:00
Mohamed Ashraf
e30bdd6748 Merge remote-tracking branch 'origin/main' into cf-1080-spotless-skip 2026-04-06 16:18:05 +00:00
Sarthak Agarwal
94e1b02597
Merge pull request #1967 from codeflash-ai/docs/update-java-documentation
docs: update Java documentation to match actual implementation
2026-04-06 18:39:07 +05:30