Skip to content

Comments

Add test coverage for cache staleness detection functions#4

Merged
Kadajett merged 3 commits intofeature/sem-45from
copilot/sub-pr-2-again
Dec 5, 2025
Merged

Add test coverage for cache staleness detection functions#4
Kadajett merged 3 commits intofeature/sem-45from
copilot/sub-pr-2-again

Conversation

Copy link

Copilot AI commented Dec 5, 2025

The staleness detection functions (is_layer_stale, is_base_layer_stale, is_branch_layer_stale, is_working_layer_stale) lacked test coverage for critical cache invalidation logic.

Changes

Basic staleness scenarios:

  • Missing cached layers
  • Missing indexed SHA metadata
  • Correct dispatch to layer-specific staleness checks

Working layer staleness:

  • File modification time vs. cache timestamp
  • Deleted/missing tracked files
  • Empty file tracking

Git integration scenarios:

  • Base layer: HEAD movement on main/master
  • Branch layer: HEAD movement on feature branch
  • Branch layer: merge-base changes after rebase

Edge cases:

  • Missing git references (no commits)
  • Detached HEAD state
  • Layered index staleness propagation

All tests use real git repositories to validate actual git workflows (commits, branches, rebases) rather than mocking.

Example

#[test]
fn test_is_branch_layer_stale_merge_base_changed() {
    // Create feature branch from main
    // Make commits on both branches
    // Verify layer is not stale (merge-base unchanged)
    
    // Rebase feature onto main
    // Verify layer is stale (HEAD SHA changed)
}

15 new tests added, all passing (162 total).


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits December 5, 2025 01:15
- Added tests for is_layer_stale with missing layers
- Added tests for is_base_layer_stale with missing indexed SHA
- Added tests for is_branch_layer_stale with missing indexed SHA
- Added tests for is_working_layer_stale with no files, deleted files, modified files, and unmodified files
- Added git integration tests for base layer staleness when HEAD changes
- Added git integration tests for branch layer staleness when HEAD moves
- Added git integration tests for branch layer staleness when merge-base changes (rebase scenarios)
- Added edge case tests for missing git refs
- Added edge case tests for detached HEAD scenarios
- Added tests for is_layer_stale dispatching to correct functions
- Added tests for is_layered_index_stale with no cache and stale base layer

All 15 new tests pass along with existing 147 tests (162 total).

Co-authored-by: Kadajett <3784716+Kadajett@users.noreply.github.com>
- Extract magic number to named constant FUTURE_OFFSET_SECONDS
- Improve assertion clarity in edge case test with match pattern

Co-authored-by: Kadajett <3784716+Kadajett@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback on overlay layer architecture cache integration Add test coverage for cache staleness detection functions Dec 5, 2025
Copilot AI requested a review from Kadajett December 5, 2025 01:21
@Kadajett Kadajett marked this pull request as ready for review December 5, 2025 01:25
@Kadajett Kadajett merged commit b0b9da7 into feature/sem-45 Dec 5, 2025
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.

2 participants