Skip to content

Add concurrency tests for ImportsValidator circular dependency detection #456

@avifenesh

Description

@avifenesh

Category

Test Quality

Severity

Critical

Location

crates/agnix-core/src/rules/imports.rs

Description

The ImportsValidator handles complex graph traversal with circular dependency detection and depth limits, but existing tests only cover basic happy-path scenarios. Critical error paths are untested:

  1. No tests for circular chains involving 3+ files (A->B->C->A)
  2. No tests for concurrent cache access (despite using RwLock<HashMap>)
  3. No tests for error recovery when filesystem errors occur mid-traversal
  4. No tests for depth limit edge cases (exactly at limit, one over limit)

The code uses ImportCache = Arc<RwLock<HashMap<PathBuf, Vec<Import>>>> for shared state during parallel validation, but there are no concurrency tests.

Suggested Tests

#[test]
fn test_circular_import_three_files() {
    // A imports B, B imports C, C imports A
}

#[test]
fn test_import_depth_exactly_at_limit() {
    // Chain of exactly MAX_IMPORT_DEPTH files
}

#[test]
fn test_concurrent_import_cache_access() {
    // Validate multiple files in parallel that share imports
}

Effort

Medium


Found by /audit-project multi-agent review

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesttestingTest coverage and quality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions