[PR #586] test: add cross-repo CWD attribution tests #591

Closed
opened 2026-03-02 04:14:03 +03:00 by kerem · 0 comments
Owner

Original Pull Request: https://github.com/git-ai-project/git-ai/pull/586

State: closed
Merged: Yes


test: add cross-repo CWD attribution tests

Summary

Adds 9 integration tests in a new tests/cross_repo_cwd_attribution.rs file verifying that AI attribution is correctly resolved when the agent's CWD (where the hook/checkpoint is called from) differs from the repo root(s) where files are being edited.

Scenarios covered (matching the 5 requested):

# Scenario Test(s)
1 CWD is an unrelated repo, single target repo test_cwd_different_from_repo_root_single_repo
2 CWD is unrelated, edits across 3 different repos test_cwd_different_from_repo_root_multiple_repos
3 CWD is one of the edited repos + edits in 2 other repos test_cwd_is_one_of_edited_repos_plus_others
4 CWD is a parent dir above repos (~/projects style) test_cwd_is_parent_dir_above_repos_single_repo, test_cwd_is_parent_dir_above_multiple_repos
5 CWD is parent dir, edits in deep subpaths of multiple repos test_cwd_parent_dir_edits_in_repo_subpaths, test_cwd_parent_dir_multiple_files_per_repo_subpaths

Two additional blame-level verification tests confirm that git-ai blame correctly distinguishes human vs AI lines in cross-CWD scenarios.

No production code changes — test-only PR.

Review & Testing Checklist for Human

  • Verify that in multi-repo tests (scenarios 2, 3, 5), git_ai_from_working_dir is called on one TestRepo object but applies to files across all repos — confirm that the shared GIT_AI_TEST_DB_PATH env from the calling repo doesn't mask issues that would appear in production (where each repo has its own storage)
  • Most tests only assert !attestations.is_empty() — they don't verify which files the attestations are for. Consider whether a test that writes to repo_a and repo_b could pass even if attestations were swapped between repos
  • In scenarios 1 and 4, working log assertions are placed before the commit — confirm this ordering is correct (working logs are keyed by base commit SHA at checkpoint time, so they must be read before the commit advances HEAD)
  • Only 2 of 9 tests (test_cross_repo_cwd_blame_shows_correct_attribution, test_parent_cwd_blame_correct_across_repos) verify blame line-by-line; the other 7 only check attestation presence. Decide if blame-level checks should be added to more scenarios

Notes

  • All 9 tests passed locally and on CI (Ubuntu, macOS; Windows still in progress at time of PR)
  • One bug was caught and fixed during development: working log assertions were initially placed after commits, which would fail because the working log is keyed by the base commit SHA at checkpoint time. This was corrected to check working logs before committing.
  • Tests use git_ai_from_working_dir to simulate running checkpoints from different CWDs, matching the pattern in existing multi_repo_workspace.rs tests
  • Workspace cleanup is manual via fs::remove_dir_all at test end; if tests panic, temp dirs may leak (minor issue, they're in system temp)

Link to Devin run: https://app.devin.ai/sessions/9dc8a791659f4feea7cbbd57b5a1ce61
Requested by: @svarlamov

**Original Pull Request:** https://github.com/git-ai-project/git-ai/pull/586 **State:** closed **Merged:** Yes --- # test: add cross-repo CWD attribution tests ## Summary Adds 9 integration tests in a new `tests/cross_repo_cwd_attribution.rs` file verifying that AI attribution is correctly resolved when the agent's CWD (where the hook/checkpoint is called from) differs from the repo root(s) where files are being edited. **Scenarios covered (matching the 5 requested):** | # | Scenario | Test(s) | |---|----------|---------| | 1 | CWD is an unrelated repo, single target repo | `test_cwd_different_from_repo_root_single_repo` | | 2 | CWD is unrelated, edits across 3 different repos | `test_cwd_different_from_repo_root_multiple_repos` | | 3 | CWD is one of the edited repos + edits in 2 other repos | `test_cwd_is_one_of_edited_repos_plus_others` | | 4 | CWD is a parent dir above repos (~/projects style) | `test_cwd_is_parent_dir_above_repos_single_repo`, `test_cwd_is_parent_dir_above_multiple_repos` | | 5 | CWD is parent dir, edits in deep subpaths of multiple repos | `test_cwd_parent_dir_edits_in_repo_subpaths`, `test_cwd_parent_dir_multiple_files_per_repo_subpaths` | Two additional blame-level verification tests confirm that `git-ai blame` correctly distinguishes human vs AI lines in cross-CWD scenarios. No production code changes — test-only PR. ## Review & Testing Checklist for Human - [ ] Verify that in multi-repo tests (scenarios 2, 3, 5), `git_ai_from_working_dir` is called on one `TestRepo` object but applies to files across all repos — confirm that the shared `GIT_AI_TEST_DB_PATH` env from the calling repo doesn't mask issues that would appear in production (where each repo has its own storage) - [ ] Most tests only assert `!attestations.is_empty()` — they don't verify *which* files the attestations are for. Consider whether a test that writes to repo_a and repo_b could pass even if attestations were swapped between repos - [ ] In scenarios 1 and 4, working log assertions are placed **before** the commit — confirm this ordering is correct (working logs are keyed by base commit SHA at checkpoint time, so they must be read before the commit advances HEAD) - [ ] Only 2 of 9 tests (`test_cross_repo_cwd_blame_shows_correct_attribution`, `test_parent_cwd_blame_correct_across_repos`) verify blame line-by-line; the other 7 only check attestation presence. Decide if blame-level checks should be added to more scenarios ### Notes - All 9 tests passed locally and on CI (Ubuntu, macOS; Windows still in progress at time of PR) - One bug was caught and fixed during development: working log assertions were initially placed after commits, which would fail because the working log is keyed by the base commit SHA at checkpoint time. This was corrected to check working logs before committing. - Tests use `git_ai_from_working_dir` to simulate running checkpoints from different CWDs, matching the pattern in existing `multi_repo_workspace.rs` tests - Workspace cleanup is manual via `fs::remove_dir_all` at test end; if tests panic, temp dirs may leak (minor issue, they're in system temp) --- Link to Devin run: https://app.devin.ai/sessions/9dc8a791659f4feea7cbbd57b5a1ce61 Requested by: @svarlamov
kerem 2026-03-02 04:14:03 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/git-ai#591
No description provided.