Skip to content

tests(vcs_jit): diffusion test never nests dirs, so subsystems==directories masks a field-conflation bug #953

@dekobon

Description

@dekobon

Summary

The lib integration test diffusion_counts_distinct_subsystems_and_directories (and every other JIT diffusion assertion in the workspace) uses only depth-1 file paths, so diffusion.subsystems and diffusion.directories always carry the same value — the test cannot distinguish the two fields and masks any bug that conflates them.

Location

  • tests/vcs_jit.rs:70-88 (diffusion_counts_distinct_subsystems_and_directories)
  • Corroborating: tests/vcs_jit.rs:340 and src/vcs/git/diff_parse_tests.rs:458 only assert subsystems, never the distinguishing directories value.

Evidence

The two features are defined differently in src/vcs/git/jit.rs:318-330:

subsystems.insert(top_level(&t.path));                                  // first path component
directories.insert(t.path.parent().unwrap_or_else(|| Path::new(""))); // full parent path

But the test feeds only depth-1 paths:

repo.write("src/a.rs", "alpha\nbeta\n");
repo.write("docs/b.md", "# title\nbody\n");
repo.write("root.txt", "x\n");
...
assert_eq!(report.features.diffusion.subsystems, 3);
assert_eq!(report.features.diffusion.directories, 3);

For src/a.rs the top-level component (src) and the full parent (src) are identical; likewise docs; likewise root.txt (both empty). The two HashSets therefore always have equal cardinality. A rg over the whole tree (src/, tests/) finds no test where a file lives more than one directory deep, so directories' distinguishing behavior (full parent path) is never exercised anywhere.

Expected Behavior

At least one diffusion test should touch files nested deeper than one level (e.g. src/foo/a.rs, src/bar/b.rs under one subsystem src but two directories src/foo, src/bar) so that subsystems != directories and a swap/conflation of the two fields fails.

Actual Behavior

With src/foo/a.rs + src/bar/b.rs, the correct result is subsystems = 1, directories = 2. Under the current suite a bug that computed directories from top_level(...) (yielding directories = 1) — collapsing nested directories into the subsystem count — would pass every existing assertion, including this test whose name explicitly claims to verify the two are "distinct".

Impact

The diffusion.directories feature contributes a 0.10 * ln1p(directories - 1) term to the JIT risk score (src/vcs/jit.rs:282). A regression that conflates directories with subsystems silently understates this term for deep changes (the common case in real repos) and ships undetected. The test's own name advertises coverage it does not provide.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions