Skip to content

feat: add support for incremental analysis#1049

Open
ash-heinz wants to merge 2 commits into
imDarshanGK:mainfrom
ash-heinz:feat/Add-support-for-incremental-analysis
Open

feat: add support for incremental analysis#1049
ash-heinz wants to merge 2 commits into
imDarshanGK:mainfrom
ash-heinz:feat/Add-support-for-incremental-analysis

Conversation

@ash-heinz

Copy link
Copy Markdown

Description

Adds backend support for incremental analysis so the app can analyze only changed files or changed code hunks instead of re-analyzing the full project every time.

Implemented:

  • Added a new POST /analyze/incremental/ endpoint
  • Added request/response schemas for incremental analysis
  • Added diff-based changed line detection using difflib.SequenceMatcher
  • Added support for added, modified, renamed, deleted, and unchanged files
  • Skips unchanged files and deleted files where no new code needs analysis
  • Handles renamed files using previous_path
  • Falls back to full-file analysis when a large portion of the file has changed
  • Returns metadata such as changed line ranges, changed line count, analyzed/skipped file count, and analysis time
  • Added backend tests for modified, added, deleted, and renamed file cases

Related Issue

Fixes #670

Type of change

  • Bug fix
  • New feature / enhancement
  • Documentation update
  • Test addition
  • Refactor

Checklist

  • I have read CONTRIBUTING.md
  • My branch is up to date with main
  • I have run pytest -v and all tests pass
  • I have not introduced duplicate issues or features
  • My PR title follows the format: feat/fix/docs/test: short description
  • I have added tests for new features (Level 2 and 3 issues)
  • No hardcoded secrets or API keys in my code
  • This PR is linked to a GSSoC 2026 issue

Screenshots (if frontend change)

Not applicable. This PR adds a backend API endpoint and tests only.

Test evidence

Ruff check evidence:
image

Pytest evidence:
image

Introduce incremental changed-file analysis: add services/incremental_analysis.py with logic to build per-file plans (detect changed line ranges, expand context, choose full/partial analysis) using SequenceMatcher and thresholds. Expose a new POST /analyze/incremental/ route in analyze.py that uses build_incremental_plan and returns IncrementalAnalyzeResponse, and wire imports. Add new Pydantic models to schemas.py (IncrementalFileChange, IncrementalAnalyzeRequest/Response, related response fragments) and reorganize existing explanation/suggestions models. Expand backend tests to cover added/modified/deleted/renamed incremental scenarios and inline sample fixtures; apply small formatting and linting cleanups in analyze.py and tests
@ash-heinz ash-heinz requested a review from imDarshanGK as a code owner June 16, 2026 12:37

@imDarshanGK imDarshanGK left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR includes many unrelated changes outside Issue #670 scope (health, metrics, share, upload, database, email, observability, etc.).

Please keep only incremental analysis related changes and relevant tests. Remove refactoring/cleanup in unrelated modules.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for incremental analysis (only analyze changed files)

2 participants