'git-ai stats' now resolves foreign prompts if attributions are present but the prompt is missing. #238
+412
−47
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm not 100% sure how this occurred in our repo, but I've got cases whereby we have attestations in a
git-ainote for a commit, but no prompts, which causesgit-ai statsto 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.rsdoes 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 statsworkflow, 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