[PR #238] [CLOSED] 'git-ai stats' now resolves foreign prompts if attributions are present but the prompt is missing. #351

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

📋 Pull Request Information

Original PR: https://github.com/git-ai-project/git-ai/pull/238
Author: @mm-zacharydavison
Created: 11/25/2025
Status: Closed

Base: mainHead: bugfix/stats-now-resolves-foreign-prompts


📝 Commits (1)

  • 20cc720 'git-ai stats' now resolves foreign prompts if attributions are present but the prompt is missing.

📊 Changes

2 files changed (+412 additions, -47 deletions)

View changed files

📝 src/authorship/stats.rs (+180 -4)
📝 src/git/refs.rs (+232 -43)

📄 Description

I'm not 100% sure how this occurred in our repo, but I've got cases whereby we have attestations in a git-ai note for a commit, but no prompts, which causes git-ai stats to give the wrong stats:

❯ git notes --ref=ai show f7dea7ffa83838d774e4deaac0bb653e16ff5f8a                                                                                11:02:23
apps/server/src/mcp/mcp-jwt.guard.spec.ts
  10d7219 24,83,90
apps/server/src/mcp/mcp-jwt.guard.ts
  10d7219 62
---
{
  "schema_version": "authorship/3.0.0",
  "git_ai_version": "1.0.21",
  "base_commit_sha": "f7dea7ffa83838d774e4deaac0bb653e16ff5f8a",
  "prompts": {}
}

❯ git-ai stats f7dea7ffa83838d774e4deaac0bb653e16ff5f8a                                                                                           11:02:30
you  ████████████████████████████████████████ ai
     100%                                   0%

This PR fixes this bug by trying to resolve foreign prompts (inspired by how virtual_attestations.rs does it).

I'm not entirely sure if this shouldn't be root-cause fixed elsewhere, i'm not sure how this could happen (but most likely it's squash flow, this came from a Github PR that was squashed).

However, since the performance impact only hits if this situation happens, and only in the git-ai stats workflow, I think it's a safe precaution to add.

after fix:

apps/server/src/mcp/mcp-jwt.guard.spec.ts
  10d7219 24,83,90
apps/server/src/mcp/mcp-jwt.guard.ts
  10d7219 62
---
{
  "schema_version": "authorship/3.0.0",
  "git_ai_version": "1.0.21",
  "base_commit_sha": "f7dea7ffa83838d774e4deaac0bb653e16ff5f8a",
  "prompts": {}
}

❯ git-ai stats f7dea7ffa8                                                                                                                  12:14:15
[git-ai] Stats command found commit: f7dea7ffa83838d774e4deaac0bb653e16ff5f8a refname: f7dea7ffa8
[git-ai] Resolving 1 foreign prompts for stats calculation
[git-ai] Found foreign prompt 10d7219 in note path d3/5e2f2e862b8d7b4730263ee384936ee97b20a6
you  ██████████████████████████████████░░░░░░ ai
     86%                                  14%
     100% AI code accepted | waited 3m for ai

🔄 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/238 **Author:** [@mm-zacharydavison](https://github.com/mm-zacharydavison) **Created:** 11/25/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `bugfix/stats-now-resolves-foreign-prompts` --- ### 📝 Commits (1) - [`20cc720`](https://github.com/git-ai-project/git-ai/commit/20cc720b55c6c5821b253ee76146b1712eaeadbb) 'git-ai stats' now resolves foreign prompts if attributions are present but the prompt is missing. ### 📊 Changes **2 files changed** (+412 additions, -47 deletions) <details> <summary>View changed files</summary> 📝 `src/authorship/stats.rs` (+180 -4) 📝 `src/git/refs.rs` (+232 -43) </details> ### 📄 Description I'm not 100% sure how this occurred in our repo, but I've got cases whereby we have attestations in a `git-ai` note for a commit, but no prompts, which causes `git-ai stats` to give the wrong stats: ```bash ❯ git notes --ref=ai show f7dea7ffa83838d774e4deaac0bb653e16ff5f8a 11:02:23 apps/server/src/mcp/mcp-jwt.guard.spec.ts 10d7219 24,83,90 apps/server/src/mcp/mcp-jwt.guard.ts 10d7219 62 --- { "schema_version": "authorship/3.0.0", "git_ai_version": "1.0.21", "base_commit_sha": "f7dea7ffa83838d774e4deaac0bb653e16ff5f8a", "prompts": {} } ❯ git-ai stats f7dea7ffa83838d774e4deaac0bb653e16ff5f8a 11:02:30 you ████████████████████████████████████████ ai 100% 0% ``` This PR fixes this bug by trying to resolve foreign prompts (inspired by how `virtual_attestations.rs` does it). I'm not entirely sure if this shouldn't be root-cause fixed elsewhere, i'm not sure how this could happen (but most likely it's squash flow, this came from a Github PR that was squashed). However, since the performance impact only hits if this situation happens, and only in the `git-ai stats` workflow, I think it's a safe precaution to add. after fix: ```bash apps/server/src/mcp/mcp-jwt.guard.spec.ts 10d7219 24,83,90 apps/server/src/mcp/mcp-jwt.guard.ts 10d7219 62 --- { "schema_version": "authorship/3.0.0", "git_ai_version": "1.0.21", "base_commit_sha": "f7dea7ffa83838d774e4deaac0bb653e16ff5f8a", "prompts": {} } ❯ git-ai stats f7dea7ffa8 12:14:15 [git-ai] Stats command found commit: f7dea7ffa83838d774e4deaac0bb653e16ff5f8a refname: f7dea7ffa8 [git-ai] Resolving 1 foreign prompts for stats calculation [git-ai] Found foreign prompt 10d7219 in note path d3/5e2f2e862b8d7b4730263ee384936ee97b20a6 you ██████████████████████████████████░░░░░░ ai 86% 14% 100% AI code accepted | waited 3m for ai ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-02 04:13:22 +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#351
No description provided.