Fix the claim filter for AI pull request summaries

Review the AI's codeEasy10 minStripe and Anthropic style

Your task

Your team has an AI write pull request descriptions from the diff. On a PR that only renamed variables and extracted a helper, it wrote "improves cache hit rates by about 30% and fixes a memory leak". There was no benchmark and no leak. Your team now filters every summary, so an impact claim reaches reviewers only with a link to its measurement.

An assistant wrote filter_pr_claims(sentences). It is in the editor. It has a bug. Find it and fix it.

Input and output:

  • sentences: the summary's sentences, in order.
  • Return the sentences to keep, unchanged and in their original order.

Rules the tests check:

  • A sentence is an impact claim when its lowercased text contains % or any of these stems: faster, slower, improve, reduce, leak, performance, speedup, optimiz. A stem counts anywhere, even inside a longer word, so improves and optimized count.
  • Keep an impact claim only when its lowercased text contains http, a link to the measurement. Words like "measured" or "benchmark" are not evidence on their own.
  • Keep every other sentence, including empty ones.
  • Repeated sentences are each kept or dropped on their own.

Examples

filter_pr_claims(sentences: list[str]) -> list[str]
Example 1
Inputfilter_pr_claims(["Renames cacheKey to cache_key across the module.", "This change improves cache hit rates by ~30%.", "Extracts a helper for eviction."])
Output["Renames cacheKey to cache_key across the module.", "Extracts a helper for eviction."]
Example 2
Inputfilter_pr_claims(["Fixes a memory leak in the eviction loop, see https://ci.example/bench/912."])
Output["Fixes a memory leak in the eviction loop, see https://ci.example/bench/912."]