[PR #559] [MERGED] PR #558 follow-up: replace Python script with Rust regression tests #571

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

📋 Pull Request Information

Original PR: https://github.com/git-ai-project/git-ai/pull/559
Author: @svarlamov
Created: 2/18/2026
Status: Merged
Merged: 2/18/2026
Merged by: @svarlamov

Base: mainHead: devin/1771451133-fix-pr558-lints-rust-tests


📝 Commits (3)

  • 5097eee migrate initial attributions during rebase
  • 50672ea replace Python reproduction script with Rust regression tests
  • 18fa1e6 fix rustfmt formatting

📊 Changes

3 files changed (+957 additions, -3 deletions)

View changed files

📝 src/authorship/rebase_authorship.rs (+945 -1)
📝 src/authorship/virtual_attribution.rs (+8 -1)
📝 src/git/repo_storage.rs (+4 -1)

📄 Description

Migrate INITIAL working logs after rebase, replace Python repro with Rust tests

Summary

Fixes silent loss of uncommitted AI attributions (INITIAL) when rebase rewrites commit SHAs. Working logs are keyed by commit SHA, so after rebase the old SHA's working log becomes orphaned.

Core fix (rebase_authorship.rs): New migrate_working_log_after_rebase() called after every RebaseComplete event. Two paths:

  • Only old working log exists → rename directory to new SHA
  • Both exist → copy INITIAL attributions into new SHA's working log, delete old

Secondary fix (virtual_attribution.rs): from_working_log_for_commit() now unions both checkpoint and blame file_contents, so files tracked only via committed notes aren't dropped when INITIAL covers a disjoint set of files.

Infra (repo_storage.rs): has_working_log() checks directory existence without creating it. #[allow(dead_code)] removed from delete_working_log_for_base_commit (now used).

Tests: Removes the 531-line Python reproduction script. Adds 4 unit tests and 3 regression tests using TmpRepo harness.

Review & Testing Checklist for Human

  • Merge path overwrites INITIAL on new_head: When both working logs exist, write_initial_attributions is called on the new working log — this will replace any existing INITIAL on new_head, not merge with it. Verify this is acceptable or if the new_head could ever already have its own INITIAL that should be preserved.
  • virtual_attribution.rs file_contents union: The or_insert_with gives checkpoint priority over blame. Confirm this is the correct merge semantic and that there isn't a case where blame file_contents should take precedence. Note there is no dedicated test for this change.
  • Regression tests simulate amend via RebaseComplete event: regression_initial_survives_amend_then_rebase fires two consecutive RebaseComplete events. In production, amends go through rewrite_authorship_after_commit_amend. Verify the test actually exercises the real amend codepath or acknowledge it's testing sequential rebase migration only.
  • Tests set up INITIAL manually: All tests write INITIAL directly via the working log API rather than going through the natural checkpoint → partial commit → post_commit flow. This validates migration logic but not INITIAL creation. Consider whether an end-to-end test through post_commit is needed.
  • Run cargo test --lib rebase_authorship::tests locally and confirm all 7 new tests pass in your environment.

Notes

  • No clippy warnings were introduced by these changes; all warnings in CI output are pre-existing.
  • The Python script was a full end-to-end reproduction using real git-ai and gt CLI commands. The Rust tests are more unit/integration level. There's a coverage gap for the full CLI flow, but the Rust tests are faster and more maintainable.
  • Link to Devin run: https://app.devin.ai/sessions/7ffe68fb44784c8b8e3fb9dafd3b3ccd
  • Requested by: @svarlamov

Open with Devin

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/git-ai-project/git-ai/pull/559 **Author:** [@svarlamov](https://github.com/svarlamov) **Created:** 2/18/2026 **Status:** ✅ Merged **Merged:** 2/18/2026 **Merged by:** [@svarlamov](https://github.com/svarlamov) **Base:** `main` ← **Head:** `devin/1771451133-fix-pr558-lints-rust-tests` --- ### 📝 Commits (3) - [`5097eee`](https://github.com/git-ai-project/git-ai/commit/5097eeea41aaa78667c83551aa21e38a111ee015) migrate initial attributions during rebase - [`50672ea`](https://github.com/git-ai-project/git-ai/commit/50672ea6296975b2cbaf53b0b564aaa0295b8289) replace Python reproduction script with Rust regression tests - [`18fa1e6`](https://github.com/git-ai-project/git-ai/commit/18fa1e69880ed91c742912f501a4fbd1cc22bc73) fix rustfmt formatting ### 📊 Changes **3 files changed** (+957 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `src/authorship/rebase_authorship.rs` (+945 -1) 📝 `src/authorship/virtual_attribution.rs` (+8 -1) 📝 `src/git/repo_storage.rs` (+4 -1) </details> ### 📄 Description # Migrate INITIAL working logs after rebase, replace Python repro with Rust tests ## Summary Fixes silent loss of uncommitted AI attributions (INITIAL) when rebase rewrites commit SHAs. Working logs are keyed by commit SHA, so after rebase the old SHA's working log becomes orphaned. **Core fix** (`rebase_authorship.rs`): New `migrate_working_log_after_rebase()` called after every `RebaseComplete` event. Two paths: - Only old working log exists → rename directory to new SHA - Both exist → copy INITIAL attributions into new SHA's working log, delete old **Secondary fix** (`virtual_attribution.rs`): `from_working_log_for_commit()` now unions both checkpoint and blame file_contents, so files tracked only via committed notes aren't dropped when INITIAL covers a disjoint set of files. **Infra** (`repo_storage.rs`): `has_working_log()` checks directory existence without creating it. `#[allow(dead_code)]` removed from `delete_working_log_for_base_commit` (now used). **Tests**: Removes the 531-line Python reproduction script. Adds 4 unit tests and 3 regression tests using TmpRepo harness. ## Review & Testing Checklist for Human - [ ] **Merge path overwrites INITIAL on new_head**: When both working logs exist, `write_initial_attributions` is called on the new working log — this will **replace** any existing INITIAL on new_head, not merge with it. Verify this is acceptable or if the new_head could ever already have its own INITIAL that should be preserved. - [ ] **`virtual_attribution.rs` file_contents union**: The `or_insert_with` gives checkpoint priority over blame. Confirm this is the correct merge semantic and that there isn't a case where blame file_contents should take precedence. Note there is no dedicated test for this change. - [ ] **Regression tests simulate amend via `RebaseComplete` event**: `regression_initial_survives_amend_then_rebase` fires two consecutive `RebaseComplete` events. In production, amends go through `rewrite_authorship_after_commit_amend`. Verify the test actually exercises the real amend codepath or acknowledge it's testing sequential rebase migration only. - [ ] **Tests set up INITIAL manually**: All tests write INITIAL directly via the working log API rather than going through the natural checkpoint → partial commit → post_commit flow. This validates migration logic but not INITIAL creation. Consider whether an end-to-end test through `post_commit` is needed. - [ ] Run `cargo test --lib rebase_authorship::tests` locally and confirm all 7 new tests pass in your environment. ### Notes - No clippy warnings were introduced by these changes; all warnings in CI output are pre-existing. - The Python script was a full end-to-end reproduction using real `git-ai` and `gt` CLI commands. The Rust tests are more unit/integration level. There's a coverage gap for the full CLI flow, but the Rust tests are faster and more maintainable. - Link to Devin run: https://app.devin.ai/sessions/7ffe68fb44784c8b8e3fb9dafd3b3ccd - Requested by: @svarlamov <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/git-ai-project/git-ai/pull/559" target="_blank"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1"> <img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open with Devin"> </picture> </a> <!-- devin-review-badge-end --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-02 04:14:00 +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#571
No description provided.