Commit graph

6514 commits

Author SHA1 Message Date
mohammed ahmed
8310f7f1c2
Merge pull request #2632 from codeflash-ai/codeflash/optimize-pr2627-2026-04-28T13.21.43
️ Speed up function `generate_and_validate_go_test_code` by 12% in PR #2627 (`cf-go-language-support`)
2026-04-30 22:27:27 +03:00
claude[bot]
771259872f style: auto-fix linting issues 2026-04-28 13:24:03 +00:00
codeflash-ai[bot]
412596d77d
Optimize generate_and_validate_go_test_code
The optimization defers `.strip()` until after syntax validation and test-function checks (eliminating an early temporary allocation in the 99% of cases where code passes validation) and skips constructing the large `f"LLM testgen response:\n{output.content}"` string in production by checking `IS_PRODUCTION` before calling `debug_log_sensitive_data`. This reduced string-manipulation overhead lifted throughput from 20,808 to 23,256 ops/sec (11.8% gain). The concurrency ratio remained at 0.01x because the function is CPU-bound on local parsing/validation rather than I/O.
2026-04-28 13:21:47 +00:00
claude[bot]
c869e64213 style: auto-fix linting issues 2026-04-28 12:55:14 +00:00
mohammed ahmed
02b1a34646
Merge pull request #2631 from codeflash-ai/codeflash/optimize-pr2627-2026-04-28T12.46.41
️ Speed up function `parse_and_validate_go_output` by 72% in PR #2627 (`cf-go-language-support`)
2026-04-28 15:52:32 +03:00
ali
ee71e34e51 Merge branch 'codeflash/optimize-pr2627-2026-04-28T12.46.41' of github.com:codeflash-ai/codeflash-internal into codeflash/optimize-pr2627-2026-04-28T12.46.41 2026-04-28 15:52:14 +03:00
ali
dd7cb28da9 cleaning up 2026-04-28 15:51:13 +03:00
claude[bot]
d8c659e95a fix: remove duplicate _extract_go_code_block definition
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-28 12:49:56 +00:00
mohammed ahmed
1a68a06663
Merge pull request #2630 from codeflash-ai/codeflash/optimize-pr2627-2026-04-28T12.37.22
️ Speed up function `_extract_package_from_source` by 52% in PR #2627 (`cf-go-language-support`)
2026-04-28 15:48:33 +03:00
mohammed ahmed
fc242788c4
Merge pull request #2629 from codeflash-ai/codeflash/optimize-pr2627-2026-04-28T12.32.18
️ Speed up function `get_user_prompt` by 3,905% in PR #2627 (`cf-go-language-support`)
2026-04-28 15:48:08 +03:00
mohammed ahmed
dcb28b769b
Merge pull request #2628 from codeflash-ai/codeflash/optimize-pr2627-2026-04-28T12.24.45
️ Speed up function `get_system_prompt` by 3,564% in PR #2627 (`cf-go-language-support`)
2026-04-28 15:47:40 +03:00
codeflash-ai[bot]
e61ea39fdb
Optimize parse_and_validate_go_output
The optimization replaced the DOTALL regex `GO_CODE_PATTERN.search()` with a manual linear scan (`_extract_go_code_block`) that uses `str.find()` to locate fence delimiters and validate opening/closing structure. Profiler data shows this cut the pattern-matching cost from ~628 µs to ~367 µs (41% reduction), which is the critical path for inputs with large surrounding text or many fence candidates. The manual scanner avoids regex backtracking and match-object allocation overhead while preserving identical semantics (MULTILINE anchor, optional "go" token, mandatory surrounding newlines). Test cases confirm correctness across all edge cases, with large-input tests showing 175–1236% speedup where the old regex scanned kilobytes of text repeatedly.
2026-04-28 12:46:45 +00:00
codeflash-ai[bot]
abcab26ef1
Optimize _extract_package_from_source
The regex pattern for matching Go package declarations is now compiled once at module load (`_PACKAGE_RE = re.compile(...)`) instead of being recompiled on every function call via `re.search()`. Line profiler shows the hot line (regex search) dropped from ~7.9 µs per hit to ~1.3 µs per hit, reducing total function time by 51% across 1049 invocations. The function is called during every Go test generation request (`testgen_go` extracts the package name from user source code), so eliminating repeated compilation overhead directly improves request latency.
2026-04-28 12:37:26 +00:00
codeflash-ai[bot]
854cd8f24b
Optimize get_user_prompt
The optimization wraps `get_user_prompt` with `@lru_cache(maxsize=2)`, caching file reads for the two prompt variants (sync and async). Since the function is called ~2600 times per optimization run with identical arguments (profiler shows 2628 hits, 47% spent in `exists()` checks and 37% in `read_text()`), caching eliminates all redundant I/O after the first call. The 40× speedup (66ms → 1.65ms) comes from avoiding repeated disk access to static prompt files, confirmed by test cases like `test_get_user_prompt_default_vs_explicit_false_500_iterations` showing 12,248% speedup on repeated calls.
2026-04-28 12:32:22 +00:00
codeflash-ai[bot]
478010b088
Optimize get_system_prompt
The optimization added `@lru_cache(maxsize=2)` to cache the two prompt file reads (sync and async variants), eliminating redundant disk I/O on subsequent calls with the same `is_async` parameter. Line profiler shows that in the original code, `prompt_file.exists()` (46.5% of runtime) and `read_text()` (37.1%) dominated execution, but with caching these operations occur only once per variant instead of on every call. The annotated tests confirm this: `test_get_system_prompt_performance_many_calls` improved 4786% across 100 iterations, and `test_get_system_prompt_repeated_calls_consistent` saw one call improve 11790% (63.9μs → 401ns) as the cache eliminates file system access entirely. The `.exists()` check was also removed since `read_text()` naturally raises `FileNotFoundError`, which is caught and re-raised as `ValueError` to preserve the original error message format.
2026-04-28 12:24:49 +00:00
mohammed ahmed
3d6488adda
Merge branch 'main' into cf-go-language-support 2026-04-28 15:02:31 +03:00
ali
e3178dd8bc revert logging back to debug 2026-04-28 15:00:58 +03:00
ali
a0546e22d2 feat: improve Go test generation prompts
Fix package declaration to match code under test (prevents build errors), warn
against string(int) Unicode trap, and pass package_name to system prompt.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-28 12:45:15 +03:00
codeflash-ci-bot[bot]
d5180b643a
chore: update tessl tiles 2026-04-27 (#2626)
## Summary

Automated weekly tessl tile update:
- Updated existing tiles to latest versions
- Installed newly available tiles for project dependencies

Generated by the **tessl-update** workflow.

Co-authored-by: codeflash-ci-bot[bot] <codeflash-ci-bot[bot]@users.noreply.github.com>
2026-04-27 05:12:35 -05:00
ali
778b2af459
log features 2026-04-25 11:09:54 +03:00
ali
1d6d17462e
base go support 2026-04-23 18:01:12 +02:00
codeflash-ci-bot[bot]
829bb738c6
chore: update tessl tiles 2026-04-23 (#2624)
## Summary

Automated weekly tessl tile update:
- Updated existing tiles to latest versions
- Installed newly available tiles for project dependencies

Generated by the **tessl-update** workflow.

Co-authored-by: codeflash-ci-bot[bot] <codeflash-ci-bot[bot]@users.noreply.github.com>
Co-authored-by: Kevin Turcios <106575910+KRRT7@users.noreply.github.com>
2026-04-23 08:15:41 -05:00
Kevin Turcios
a8d283736a chore: add ready-to-merge gate for branch freshness 2026-04-23 08:12:11 -05:00
Kevin Turcios
586ca2e8c1
Merge pull request #2625 from codeflash-ai/fix/missing-tiles-format
fix: use proper tile names in missing-tiles.txt
2026-04-23 08:07:16 -05:00
Kevin Turcios
430d429076 fix: use proper tile names in missing-tiles.txt 2026-04-23 08:06:55 -05:00
Kevin Turcios
1165c25602
Merge pull request #2623 from codeflash-ai/fix/tessl-app-token
fix: pass CI bot secrets to tessl update workflow
2026-04-23 08:04:55 -05:00
Kevin Turcios
65838dc916 fix: pass CI bot secrets to tessl update workflow 2026-04-23 08:04:02 -05:00
Kevin Turcios
07d2d97ba2
Merge pull request #2622 from codeflash-ai/fix/tessl-caller-permissions
fix: add permissions to tessl update caller workflow
2026-04-23 07:50:41 -05:00
Kevin Turcios
b0bf17b0ee fix: add permissions to tessl update caller workflow 2026-04-23 07:49:54 -05:00
Kevin Turcios
10ec11c25a
Merge pull request #2621 from codeflash-ai/chore/tessl-vendored-setup
chore: initialize tessl with vendored tiles
2026-04-23 07:44:55 -05:00
Kevin Turcios
235c08d342 chore: initialize tessl with vendored tiles
Switch from managed to vendored mode so tiles are committed to git.
Install 55 tiles (Python + JS/TS), add MCP configs, and set up
weekly tile update workflow via reusable github-workflows caller.
2026-04-23 07:42:51 -05:00
Kevin Turcios
235858d205
Migrate aiservice-test to shared workflow with dynamic secret env (#2620)
## Summary

- Replaces the inline `aiservice-test` job (30 lines of boilerplate)
with a 10-line shared workflow call
- Uses the new `test-secret-env` input on `ci-python-uv.yml` to
dynamically export 7 secrets as masked env vars
- Pattern: caller passes `secrets: inherit` + a JSON map of `{ENV_VAR:
SECRET_NAME}`, shared workflow uses `toJSON(secrets)` + jq to export
them with `::add-mask::`

### Before (inline)
```yaml
aiservice-test:
  runs-on: ubuntu-latest
  env:
    SECRET_KEY: ${{ secrets.SECRET_KEY }}
    DATABASE_URL: ${{ secrets.DATABASE_URL }}
    # ... 5 more hardcoded secret refs
  steps:
    - uses: actions/checkout@v6
    - uses: astral-sh/setup-uv@v8.1.0
    - run: uv sync
    - run: uv run pytest
```

### After (shared workflow)
```yaml
aiservice-test:
  uses: codeflash-ai/github-workflows/.github/workflows/ci-python-uv.yml@main
  secrets: inherit
  with:
    working-directory: "django/aiservice"
    sync-command: "uv sync"
    test-command: "uv run pytest"
    test-secret-env: '{"SECRET_KEY": "SECRET_KEY", "DATABASE_URL": "DATABASE_URL", ...}'
```

First consumer of the `test-secret-env` feature — validates the pattern
for future jobs.

## Test plan

- [ ] CI passes — aiservice-test job runs via shared workflow and
secrets are correctly exported
- [ ] Gate job (required-checks-passed) still works with the new job
structure
- [ ] No regression in other jobs (they're unchanged)
2026-04-23 06:00:11 -05:00
Kevin Turcios
eeecdc11d7
Bump stale GitHub Actions versions (#2618)
## Summary

Bumps all stale GitHub Actions to their latest stable versions across 7
workflow files.

### Changes

| Workflow | Action | Old | New |
|---|---|---|---|
| `ci.yaml` | `astral-sh/setup-uv` | `@v8.0.0` / `@v7` (inline jobs
only) | `@v8.1.0` |
| `claude.yml` | `astral-sh/setup-uv` | `@v6` | `@v8.1.0` |
| `codeflash-aiservice.yaml` | `astral-sh/setup-uv` | `@v7` | `@v8.1.0`
|
| `codeflash-js.yaml` | `astral-sh/setup-uv` | `@v7` | `@v8.1.0` |
| `deploy_aiservice_to_azure.yml` | `astral-sh/setup-uv` | `@v7` |
`@v8.1.0` |
| `fix-formatting.yml` | `astral-sh/setup-uv` | `@v5` | `@v8.1.0` |
| `fix-formatting.yml` | `j178/prek-action` | `@v1` | `@v2` |
| `publish-to-pypi.yml` | `pypa/gh-action-pypi-publish` | `@master` |
`@release/v1` |

### Notes

- Shared workflow refs (`codeflash-ai/github-workflows/...@main`) in
`ci.yaml` are **not** changed -- those follow `@main` and will pick up
updates from the shared workflows repo.
- `publish-to-pypi.yml` is currently disabled (`if: false`) but the ref
is fixed anyway to avoid issues when re-enabled.

## Test plan

- [ ] CI passes on this PR (the workflow files themselves are the
change, so CI validates they parse correctly)
- [ ] Verify `ci.yaml` shared workflow `uses:` lines still reference
`@main`
2026-04-23 05:49:17 -05:00
Kevin Turcios
0d968a0652
Fix VSCode extension build: regenerate package-lock.json (#2617)
## Summary

- Snyk PR #2305 bumped `diff` from 8.0.2 to 8.0.3 in
`js/VSC-Extension/package.json` without regenerating the lockfile
- This causes `npm ci` to fail with a "package.json and
package-lock.json are in sync" error
- Ran `npm install` to regenerate `package-lock.json` (resolves `diff`
to 8.0.4, the latest matching `^8.0.3`)

## Test plan

- [x] Verified `npm ci` succeeds with the updated lockfile
- [x] Diff is minimal: only the `diff` package version change (4
insertions, 4 deletions)
2026-04-23 05:44:18 -05:00
Kevin Turcios
72cb04ead1
Remove old CI workflow files (consolidated into ci.yaml) (#2616)
Delete 7 separate workflow files now replaced by the unified ci.yaml:
aiservice-ci.yml, cf-api-tests.yaml, cf-webapp-quality-gates.yml,
end-to-end-tests.yaml, nextjs-build.yaml, prek.yaml,
vscode-extension-build.yml
2026-04-23 05:32:30 -05:00
Kevin Turcios
cf28fa6299
Consolidate CI into single workflow with shared actions (#2614)
Replace 7 separate CI workflow files with a unified ci.yaml that uses
shared workflows from codeflash-ai/github-workflows:

- determine-changes: reusable workflow for path-based change detection
- prek-lint: reusable workflow for pre-commit checks
- ci-python-uv: reusable workflow for Python typecheck
- required-checks-gate: composite action for gate job

All downstream jobs use fromJSON(needs.determine-changes.outputs.flags)
for conditional execution. A single required-checks-passed gate job
replaces per-workflow required checks.

Private repos need explicit permissions on reusable workflow calls
(contents:write for prek) since they don't inherit permissive defaults.
2026-04-23 05:26:05 -05:00
Kevin Turcios
d4ad423273
Unpin claude-code-action from v1.0.89 to @v1
Bedrock SigV4 auth regression (anthropics/claude-code-action#1193) was fixed in Claude Code 2.1.97, shipped in v1.0.91. Latest is v1.0.104.
2026-04-23 04:10:10 -05:00
Kevin Turcios
3d1b843da4 Fix code repair for raw (non-markdown) source code input
The Python client sends raw source code, not markdown-wrapped blocks.
split_markdown_code() returned {} for raw input, making SearchAndReplaceDiff
have nothing to patch, so repairs always returned empty string.

Now falls back to {"file.py": raw_code} when markdown parsing yields nothing,
and is_valid() handles raw code blocks instead of only markdown-wrapped ones.
2026-04-21 20:42:01 -05:00
Kevin Turcios
34eb74342d Improve code repair prompts and test detail formatting
System prompt now focuses on repair strategy (identify pattern, compare
code, minimal fix) instead of spending most tokens on SEARCH/REPLACE
format spec. User prompt explicitly frames the task and asks for root
cause analysis. build_test_details() reformatted for clarity: grouped
by test source with clear Expected/Got lines separated by --- dividers.
2026-04-21 17:54:03 -05:00
Aseem Saxena
a3f0c07bb6
fix: allow Monaco editor CDN in CSP for trace page diffs (#2611)
## Summary
- The Monaco diff editor on `/trace/[id]` pages was not loading because
`@monaco-editor/react` fetches JS, CSS, and font assets from
`cdn.jsdelivr.net` by default
- The Content Security Policy in `next.config.mjs` blocked those
requests (missing from `script-src`, `style-src`, `font-src`)
- Added `https://cdn.jsdelivr.net` to the three relevant CSP directives

## Test plan
- [ ] Open a trace page (e.g.
`/trace/c0668bd3-9321-4082-9c43-3e41bdd9b1c5`) and verify the code diff
renders
- [ ] Check browser console for no remaining CSP violations
- [ ] Verify no regressions on other pages

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Sarthak Agarwal <sarthak.saga@gmail.com>
2026-04-22 04:07:40 +05:30
Kevin Turcios
f9c6376f14 Strengthen test examples prompt to emphasize behavioral correctness
Reworded to highlight that hand-written unit tests encode the developer's
explicit behavioral expectations and that optimizations must produce
identical results for all test cases.
2026-04-21 17:06:40 -05:00
Kevin Turcios
ccfe0998e7 Wire baseline runtime, test examples, and LP diversity into optimizer
Accept baseline_runtime_ns, loop_count, line_profiler_results, and
test_input_examples on the optimize endpoint. Pass runtime context
and test examples to the user prompt so the LLM can generate
better-informed candidates. Alternate line profiler data across
parallel calls for diversity (odd calls get LP, even calls don't).
2026-04-21 15:48:47 -05:00
Kevin Turcios
9b3cd48048 Raise LLMOutputUnparseable on empty LLM responses instead of silently returning ""
When Azure OpenAI or Anthropic returns null/empty content (content
filter, truncation, transient failure), call_openai/call_anthropic now
raise LLMOutputUnparseable instead of returning an empty string that
silently flows through the pipeline and produces 422 "Could not
generate any optimizations." All optimizer callers catch
LLMOutputUnparseable to preserve cost tracking while returning None.
2026-04-21 05:59:07 -05:00
Saurabh Misra
7355b05663
Merge pull request #2610 from codeflash-ai/cf-rl-env-catalog
Codeflash RL Environment for Roboflow Inference to train AI Agents for optimization
2026-04-16 16:35:50 -07:00
Saurabh Misra
9d4ecd07e8
Merge branch 'main' into cf-rl-env-catalog 2026-04-16 16:35:27 -07:00
misrasaurabh1
2a101a11f2 add universe optimize orchestrator with project management, 2026-04-16 16:34:36 -07:00
misrasaurabh1
a52d80b0aa add missing_commits_bundle_note.txt to base-image 2026-04-16 16:34:05 -07:00
misrasaurabh1
b3f164dcda rl env files 2026-04-16 16:31:25 -07:00
Kevin Turcios
791ee34f0d fix: target codeflash-webapp-2 staging with standalone deploy 2026-04-15 07:55:42 -05:00
Kevin Turcios
e1c1f13701 revert: drop node-linker=hoisted from .npmrc
node-linker=hoisted triggers an Invalid Version bug in pnpm 10 bin
linking. The standalone output with zip -y (symlink preservation) is
sufficient — Azure SquashFS supports symlinks natively.
2026-04-15 07:47:35 -05:00