[PR #505] Speed up single-commit stats by deriving accepted lines from authorship notes #522

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

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

State: closed
Merged: Yes


Motivation

  • Single-commit stats were slow because they invoked an expensive diff/blame-style analysis (diff_ai_accepted_stats) even for one commit, causing large commits to block UI/post-commit flow.
  • Merge commits and conflict-resolution commits do not need diff-based accepted-line attribution and should be fast-skipped.

Description

  • Replace the expensive diff-based acceptance pass for single-commit stats with accepted_lines_from_attestations, which derives accepted AI lines by summing attestation LineRanges from the commit authorship note and aggregates per-tool/model using prompt metadata, preserving output shape while being O(attestation entries) instead of running full diff/blame logic.
  • Add a merge-commit fast-path: when a commit has multiple parents the accepted-line calculation returns 0 and per-tool buckets are empty to avoid unnecessary work for merges.
  • Update post-commit flow to detect merge commits early and skip stats calculation entirely (introducing StatsSkipReason), and emit explicit debug and user-facing skip messages distinguishing merge commits from large/expensive commits.
  • Add a regression unit test test_stats_for_merge_commit_skips_ai_acceptance to guard merge behavior and ensure ai_accepted is zero for merge commits.

Testing

  • Ran code formatting with cargo fmt successfully.
  • Executed unit tests: test_stats_for_merge_commit_skips_ai_acceptance passed.
  • Executed unit tests: test_stats_for_simple_ai_commit passed.
  • Executed unit tests: test_stats_for_mixed_commit passed.

Codex Task


Open with Devin
**Original Pull Request:** https://github.com/git-ai-project/git-ai/pull/505 **State:** closed **Merged:** Yes --- ### Motivation - Single-commit stats were slow because they invoked an expensive diff/blame-style analysis (`diff_ai_accepted_stats`) even for one commit, causing large commits to block UI/post-commit flow. - Merge commits and conflict-resolution commits do not need diff-based accepted-line attribution and should be fast-skipped. ### Description - Replace the expensive diff-based acceptance pass for single-commit stats with `accepted_lines_from_attestations`, which derives accepted AI lines by summing attestation `LineRange`s from the commit authorship note and aggregates per-tool/model using prompt metadata, preserving output shape while being O(attestation entries) instead of running full diff/blame logic. - Add a merge-commit fast-path: when a commit has multiple parents the accepted-line calculation returns `0` and per-tool buckets are empty to avoid unnecessary work for merges. - Update post-commit flow to detect merge commits early and skip stats calculation entirely (introducing `StatsSkipReason`), and emit explicit debug and user-facing skip messages distinguishing merge commits from large/expensive commits. - Add a regression unit test `test_stats_for_merge_commit_skips_ai_acceptance` to guard merge behavior and ensure `ai_accepted` is zero for merge commits. ### Testing - Ran code formatting with `cargo fmt` successfully. - Executed unit tests: `test_stats_for_merge_commit_skips_ai_acceptance` passed. - Executed unit tests: `test_stats_for_simple_ai_commit` passed. - Executed unit tests: `test_stats_for_mixed_commit` passed. ------ [Codex Task](https://chatgpt.com/codex/tasks/task_e_698c06912d6c832c9119785824117be5) <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/git-ai-project/git-ai/pull/505" 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 -->
kerem 2026-03-02 04:13:52 +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#522
No description provided.