Skip to content

Implement incremental validation — only re-analyze changed files #13

@rudra496

Description

@rudra496

Summary

The cache system exists (cache.py) but currently only caches file hashes. Implement true incremental validation that:

  1. Tracks file modification times and content hashes
  2. Only re-analyzes files that changed since last validation
  3. Supports dependency-aware invalidation (if a.py imports b.py and b.py changes, re-analyze a.py too)

Current State

The cache.py module exists but needs enhancement. The multi_file.py handles dependency analysis.

Implementation Plan

  1. Content-addressed cache: Store {file_hash: ValidationResult} instead of {file_path: ValidationResult}
  2. Dependency graph: Build import graph, invalidate dependents when a file changes
  3. Incremental mode flag: aitrust validate src/ --incremental
  4. Cache manifest: Store .aitrust_cache/manifest.json with file paths, hashes, and timestamps
  5. Smart invalidation: Only re-analyze if file content hash changed

Performance Target

  • First run: same as current (full analysis)
  • Second run (no changes): <100ms (just cache lookup)
  • Second run (1 file changed): analyze only that file + dependents

Acceptance Criteria

  • --incremental flag works
  • Unchanged files served from cache
  • Dependency-aware invalidation
  • Cache manifest persisted between runs
  • Benchmark showing >10x speedup on unchanged codebases
  • Tests

Difficulty

Advanced — requires careful cache invalidation logic and dependency tracking.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions