Commit graph

125 commits

Author SHA1 Message Date
Kevin Turcios
add5f4a76a
feat: migrate from psycopg2 to psycopg3 with connection pooling (#2489)
## Summary
- Replaces `psycopg2-binary` with `psycopg[binary,pool]>=3.1.8,<4` for
native async connection pooling
- Sets `conn_max_age=0` (persistent connections don't work correctly
under ASGI) and configures psycopg3's `ConnectionPool` with `min_size=2,
max_size=10`
- Changes `log_features` to use `@sync_to_async(thread_sensitive=False)`
so concurrent calls dispatch to different threads, each getting a
separate connection from the pool

## Why
With psycopg2, all `sync_to_async` calls from the same coroutine shared
a single thread and Postgres connection. Parallel DB calls via
`TaskGroup` were serialized at the connection level — zero improvement.
Benchmarks confirmed that with psycopg3's pool, 5 parallel calls now get
5 different threads and 5 different `pg_backend_pid`s. Parallel
`aexists` operations showed **15.6% improvement** (208ms → 175ms).

## Test plan
- [x] 538 tests pass, 0 failures, 12 skipped (pre-existing)
- [x] Ruff lint clean
- [x] Benchmark confirms multiple connections: 5 unique threads, 5
unique pg_pids
- [ ] Verify in staging that connection pool behaves correctly under
sustained load
2026-03-27 05:33:33 -05:00
Sarthak Agarwal
eb5f4b460e
Migrate to AWS bedrock (#2430)
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_REGION=us-east-1



Will require these for boto3 authentication
2026-02-20 23:52:48 +05:30
Kevin Turcios
2614393793
Add test_index to LLM call context for observability chat (#2414)
## Summary

- Pass test_index through LLM call context so observability chat can
attribute responses to specific test generation calls
- Fix SSE streaming to send keepalive pings from the start

CF-504
2026-02-13 23:49:20 -05:00
Saurabh Misra
198c0c1a4e
codeflash-omni-java (#2335)
# Pull Request Checklist

## Description
- [ ] **Breaking Changes**: Document any breaking changes (if
applicable)
- [ ] **Description of PR**: Clear and concise description of what this
PR accomplishes
- [ ] **Related Issues**: Link to any related issues or tickets

## Testing
- [ ] **Test cases Attached**: All relevant test cases have been
added/updated
- [ ] **Manual Testing**: Manual testing completed for the changes

## Monitoring & Debugging
- [ ] **Logging in place**: Appropriate logging has been added for
debugging user issues
- [ ] **Sentry will be able to catch errors**: Error handling ensures
Sentry can capture and report errors
- [ ] **Avoid Dev based/Prisma logging**: No development-only or
Prisma-specific logging in production code

## Configuration
- [ ] **Env variables newly added**: Any new environment variables are
documented in .env.example file or mentioned in description
---

## Additional Notes
<!-- Add any additional context, screenshots, or notes for reviewers
here -->

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com>
Co-authored-by: HeshamHM28 <HeshamMohamedFathy@outlook.com>
Co-authored-by: Ubuntu <ubuntu@ip-172-31-39-200.ec2.internal>
Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
Co-authored-by: Kevin Turcios <turcioskevinr@gmail.com>
Co-authored-by: Kevin Turcios <106575910+KRRT7@users.noreply.github.com>
2026-02-13 23:26:55 +05:30
Kevin Turcios
629442cc5e
Restructure aiservice to language-first architecture (#2383)
## Summary
- Reorganizes `django/aiservice/` from feature-first layout (separate
`optimizer/`, `testgen/`, `code_repair/` dirs) to language-first layout
under `core/languages/{python,js_ts}/`
- Adds handler/registry/dispatcher pattern for routing requests to
language-specific implementations
- All existing module code preserved via `git mv` for history tracking;
no logic changes to existing modules

## What changed
- New `core/` app with registry, dispatcher, protocols, and error
hierarchy
- `PythonHandler` and `JSTypeScriptHandler` delegate to existing module
functions
- All imports updated across the codebase (views, tests,
adaptive_optimizer, etc.)
- Integration tests for handler registration and dispatch
- 155 files changed, ~880 additions / ~207 deletions (mostly import path
updates and moves)

## Test plan
- [ ] `python manage.py check` passes
- [ ] Integration tests in
`tests/integration/test_handler_integration.py` pass
- [ ] Existing test suite passes with updated import paths
- [ ] Ruff and ty clean on all new infrastructure files

---------

Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com>
2026-02-09 09:15:50 -05:00
ali
f0480fac39
use treesitter for validating js & ts code syntax 2026-01-28 23:15:30 +02:00
Kevin Turcios
0444e32f77
fix: CST tree handling and testgen pipeline improvements (#2310)
## Summary
- Fix CST tree corruption issues that caused 'NoneType' object has no
attribute 'visit' errors
- Consolidate testgen postprocessing into a single pipeline with
tuple-based pattern
- Improve markdown code extraction to prefer filepath-annotated blocks
- Add diagnostic context to optimization failure logs

## Changes
- Handle empty `SimpleStatementLine` and `StatementHandler` body to
prevent malformed CST
- Add trace_id logging to optimization and import failure paths
- Refactor testgen postprocessing into consolidated pipeline
- Fix code extraction for LLM responses with multiple code blocks

## Test plan
- [x] Added integration tests for full testgen pipeline
- [x] Added tests for markdown extraction with filepath preference
- [x] Existing tests pass

---------

Co-authored-by: codeflash-ai[bot] <148906541+codeflash-ai[bot]@users.noreply.github.com>
2026-01-26 23:57:55 -05:00
Kevin Turcios
d091cd17fe
refactor: consolidate shared utilities (#2289)
- Consolidate shared utilities into `aiservice/common/`
- Remove profanity filtering from optimization pipeline
- Add unit tests for common module
2026-01-25 00:49:48 -05:00
Sarthak Agarwal
7bef00afa3
delete the package causing issue (#2220)
Co-authored-by: Kevin Turcios <106575910+KRRT7@users.noreply.github.com>
2026-01-10 01:05:06 +05:30
Kevin Turcios
a906d651cd use speedups 2026-01-09 00:07:14 -05:00
Kevin Turcios
1d1ec35cc3 typed dict runtime eval 2026-01-09 00:05:30 -05:00
Kevin Turcios
a2c0ef6573 Merge main into ty-setup branch 2025-12-30 14:50:29 -05:00
Kevin Turcios
5b91b0e047 fix these type hints 2025-12-30 01:53:44 -05:00
Kevin Turcios
2d4751a2f0 add pre-k to dependencies 2025-12-30 01:17:03 -05:00
Kevin Turcios
38f3e5c683 add ty type checker 2025-12-30 01:10:26 -05:00
Kevin Turcios
6f45e0d0f1 make ruff and ty happy 2025-12-26 18:55:45 -05:00
Kevin Turcios
3b79fd8c2d add anthropic to pyproject 2025-12-22 18:29:38 -05:00
Kevin Turcios
69c9938fa6 restore jedi 2025-10-31 15:22:38 -05:00
Kevin Turcios
b7c60ffa86 move jedi too 2025-10-31 12:54:44 -05:00
Kevin Turcios
ed3a339a3d pytest django 2025-10-31 12:53:20 -05:00
Kevin Turcios
9d4c396797 move pytest 2025-10-31 12:52:38 -05:00
Kevin Turcios
222f49040b remove black from dependencies 2025-10-31 12:51:35 -05:00
Kevin Turcios
4bac062dde Revert "Memory Profiling (Will revert later) (#1949)"
This reverts commit 867c6b6a2f.
2025-10-31 05:14:51 -05:00
Sarthak Agarwal
867c6b6a2f
Memory Profiling (Will revert later) (#1949)
<img width="1427" height="165" alt="image"
src="https://github.com/user-attachments/assets/b3534e91-4b7d-4c25-b4c2-ac13650a8cdf"
/>

How to Test:
```
Start the server with memory profiling enabled:

  PYTHONUNBUFFERED=1 ENABLE_MEMORY_PROFILING=true uv run uvicorn aiservice.asgi:application --host 0.0.0.0 --port 8888 2>&1

  Double check the output on startup:
  🔬 Memory profiling middleware enabled
  

  Make a test request :
  curl -X POST http://localhost:8888/ai/testgen \
    -H "Content-Type: application/json" \
    -d @test_payload.json

  Expected memory profiling output:
MEMORY_PROFILE | endpoint=/ai/testgen | mem_before=160.7MB | mem_after=208.5MB | delta=+47.73MB | worker_pid=97255
  ```

---------

Co-authored-by: Aseem Saxena <aseem.bits@gmail.com>
2025-10-30 18:10:02 -07:00
Kevin Turcios
20dfe0bec6 add aiohttp to dependencies 2025-10-28 19:56:13 -05:00
Kevin Turcios
84c59dba1b revert local dev changes 2025-10-18 00:55:48 -07:00
Kevin Turcios
72a356de8c temp 2025-10-17 22:11:20 -07:00
Kevin Turcios
4bb592541d enable sentry logging 2025-10-17 13:13:34 -07:00
Kevin Turcios
26e1e7b37e stray rich 2025-10-17 02:45:08 -07:00
Kevin Turcios
7f6e6f2f2c better error handling if the FTO src code is invalid 2025-10-17 01:31:14 -07:00
Kevin Turcios
d025f5b8be temp 2025-10-16 21:45:54 -07:00
Kevin Turcios
efdfc4068b upgrade isort 2025-10-16 21:45:13 -07:00
Kevin Turcios
4248383a5f lock refresh, no stamina 2025-10-15 11:53:24 -07:00
Kevin Turcios
8062865f5c add stamina for nice retrying 2025-10-14 15:32:52 -07:00
Kevin Turcios
0d1bec6d27 dataclasses too 2025-10-14 14:50:30 -07:00
Kevin Turcios
5646b3da35 allow async optimizations 2025-10-01 15:49:13 -07:00
Saurabh Misra
4be038b3f9 minor
Signed-off-by: Saurabh Misra <misra.saurabh1@gmail.com>
2025-08-20 12:19:04 -07:00
Kevin Turcios
31034bc503 update rules 2025-08-07 13:12:09 -07:00
Kevin Turcios
af3cd6b926 allow async tests 2025-08-06 16:12:25 -07:00
aseembits93
c520519555 ignoring precommit hooks 2025-07-29 11:12:36 -07:00
Kevin Turcios
12e91550e2 remove nltk 2025-06-17 12:36:49 -07:00
Aseem Saxena
4dc2c5881a cleaning up 2025-04-21 13:16:49 -07:00
Aseem Saxena
0b58b3e7cc add litelmm as a dependency 2025-04-17 16:21:53 -07:00
Aseem Saxena
116c792502 wip 2025-04-02 17:07:50 -07:00
Alvin Ryanputra
ffe6871cd1 updated pyproject toml 2025-03-05 12:17:15 -08:00
Kevin Turcios
1ad44c3716 Update pyproject.toml 2025-03-04 17:46:14 -08:00
Kevin Turcios
50911c0130 Update pyproject.toml 2025-03-04 17:44:20 -08:00
Kevin Turcios
e75122fe6f Update pyproject.toml 2025-03-04 17:29:29 -08:00
Kevin Turcios
f7c2300a4f Update pyproject.toml 2025-03-04 17:27:42 -08:00
Kevin Turcios
597dc11d09 Update pyproject.toml 2025-03-04 17:26:13 -08:00