Fix CLAUDE.md accuracy: remove nonexistent files, update patterns
- Remove _line_profiler.py, observability/models.py, _optimizer.py, _rate_limit.py, _usage.py from tree (never created) - Add _background.py, _markdown.py, _xml.py that actually exist - Mark java/ and js_ts/ as stubs - Update endpoint count from 15 to 14, note log_features stub - Fix Depends() example to use Annotated[] pattern - Add deferred items: optimize-line-profiler, observability DB writes
This commit is contained in:
parent
3a07579bb0
commit
fb76024cfb
1 changed files with 16 additions and 23 deletions
|
|
@ -19,9 +19,7 @@ src/codeflash_api/
|
|||
│
|
||||
├── auth/ # Authentication & authorization
|
||||
│ ├── _keys.py # API key hashing (SHA-384), lookup
|
||||
│ ├── _deps.py # FastAPI dependencies: get_current_user, require_auth
|
||||
│ ├── _rate_limit.py # Per-user per-endpoint rate limiting
|
||||
│ ├── _usage.py # Subscription quota tracking
|
||||
│ ├── _deps.py # FastAPI dependencies: require_auth, check_rate_limit, track_usage
|
||||
│ └── models.py # User, Organization, Subscription, APIKey (attrs)
|
||||
│
|
||||
├── llm/ # LLM provider abstraction
|
||||
|
|
@ -36,14 +34,13 @@ src/codeflash_api/
|
|||
│ └── models.py # Table schemas as attrs classes (not ORM models)
|
||||
│
|
||||
├── observability/ # LLM call recording, error tracking
|
||||
│ ├── _recording.py # Fire-and-forget async recording
|
||||
│ └── models.py # LLMCall, OptimizationError (attrs)
|
||||
│ ├── _background.py # Fire-and-forget background task management
|
||||
│ └── _recording.py # LLM call and error recording (log-only, DB deferred)
|
||||
│
|
||||
├── optimize/ # Core optimization pipeline
|
||||
│ ├── _router.py # POST /ai/optimize — language dispatch
|
||||
│ ├── _pipeline.py # Parallel LLM orchestration, model distribution
|
||||
│ ├── _context.py # Prompt assembly (system + user), runtime context
|
||||
│ ├── _line_profiler.py # POST /ai/optimize-line-profiler
|
||||
│ └── schemas.py # Request/response Pydantic models
|
||||
│
|
||||
├── repair/ # Code repair pipeline
|
||||
|
|
@ -91,19 +88,14 @@ src/codeflash_api/
|
|||
│
|
||||
├── languages/ # Language-specific logic
|
||||
│ ├── python/
|
||||
│ │ ├── _optimizer.py # Python optimization handler
|
||||
│ │ ├── _postprocess.py # Dedup, validation, cleanup (~520 lines)
|
||||
│ │ ├── _cst_utils.py # libcst utilities (~450 lines)
|
||||
│ │ ├── _postprocess.py # Dedup, validation, cleanup (~830 lines)
|
||||
│ │ ├── _cst_utils.py # libcst utilities (~470 lines)
|
||||
│ │ ├── _validator.py # Python syntax validation (libcst + ast)
|
||||
│ │ ├── _markdown.py # Markdown code block extraction
|
||||
│ │ ├── _xml.py # XML tag extraction for Anthropic responses
|
||||
│ │ └── prompts/ # .md prompt templates
|
||||
│ ├── java/
|
||||
│ │ ├── _optimizer.py
|
||||
│ │ ├── _validator.py # tree-sitter-java
|
||||
│ │ └── prompts/
|
||||
│ └── js_ts/
|
||||
│ ├── _optimizer.py
|
||||
│ ├── _validator.py # tree-sitter-javascript/typescript
|
||||
│ └── prompts/
|
||||
│ ├── java/ # Stub — P2, deferred
|
||||
│ └── js_ts/ # Stub — P2, deferred
|
||||
│
|
||||
└── diff/ # Diff patch application
|
||||
├── _base.py # Diff ABC, DiffMethod enum
|
||||
|
|
@ -128,13 +120,12 @@ Infrastructure (llm, db, observability) ← asyncpg, openai, anthropic
|
|||
|
||||
Dependency direction is strictly downward. Routers never import from each other. Language modules never import from routers. Infrastructure never imports from pipeline.
|
||||
|
||||
### Endpoints (15 total)
|
||||
### Endpoints (14 total)
|
||||
|
||||
| Endpoint | Method | Module |
|
||||
|---|---|---|
|
||||
| `/healthcheck` | GET | `_app.py` |
|
||||
| `/ai/optimize` | POST | `optimize/_router.py` |
|
||||
| `/ai/optimize-line-profiler` | POST | `optimize/_line_profiler.py` |
|
||||
| `/ai/refinement` | POST | `refinement/_router.py` |
|
||||
| `/ai/code_repair` | POST | `repair/_router.py` |
|
||||
| `/ai/adaptive_optimize` | POST | `adaptive/_router.py` |
|
||||
|
|
@ -146,7 +137,7 @@ Dependency direction is strictly downward. Routers never import from each other.
|
|||
| `/ai/optimization_review` | POST | `review/_router.py` |
|
||||
| `/ai/rewrite_jit` | POST | `jit/_router.py` |
|
||||
| `/ai/workflow-gen` | POST | `workflow/_router.py` |
|
||||
| `/ai/log_features` | POST | `logging/_router.py` |
|
||||
| `/ai/log_features` | POST | `logging/_router.py` (stub — DB upsert deferred) |
|
||||
|
||||
### Key design decisions
|
||||
|
||||
|
|
@ -159,9 +150,9 @@ Dependency direction is strictly downward. Routers never import from each other.
|
|||
@router.post("/ai/optimize")
|
||||
async def optimize(
|
||||
request: OptimizeSchema,
|
||||
user: AuthenticatedUser = Depends(require_auth),
|
||||
_rate: None = Depends(check_rate_limit),
|
||||
_usage: None = Depends(track_usage),
|
||||
user: Annotated[AuthenticatedUser, Depends(require_auth)],
|
||||
_rate: Annotated[None, Depends(check_rate_limit)],
|
||||
_usage: Annotated[None, Depends(track_usage)],
|
||||
) -> OptimizeResponse:
|
||||
```
|
||||
|
||||
|
|
@ -207,8 +198,10 @@ All 9 steps complete. 13/13 endpoints implemented (12 full, 1 stub: `/ai/log_fea
|
|||
|
||||
### Deferred work
|
||||
|
||||
- **`/ai/optimize-line-profiler` endpoint** — Nearly identical to `/ai/optimize`, not yet implemented.
|
||||
- **Testgen postprocessing** — CST transformation pipeline (remove helpers, unused defs, cap loops/tensors, add imports, remove asserts).
|
||||
- **DB persistence for log_features** — asyncpg upsert for optimization_features table.
|
||||
- **Observability DB persistence** — `_recording.py` is log-only; asyncpg writes for `llm_calls` and `optimization_errors` tables deferred.
|
||||
- **JS/TS and Java language layers** — P2, after Python pipeline is production-validated.
|
||||
- **CI pipeline** — GitHub Actions for lint, test, type check, deploy.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue