Here's the PR body:
## Summary
Checkout called the FX provider on every cart render. During Friday's sale that went over the provider's 1,000 requests/minute limit, and checkout started returning 429 errors. `get_rate` now keeps each rate in memory for 5 minutes.
```diff
get_rate(base, quote)
+ if base:quote was fetched less than 300s ago
+ return the saved rate
GET api.example-fx.com/latest
raise on HTTP error
+ save rate for base:quote with time.monotonic()
return rate
Evidence
-
Before:
pytestshows 14 passed. Everyget_ratecall makes its own HTTP request.
After:pytestshows 15 passed. Addedtest_get_rate_uses_cache_within_ttl:get_rate("USD", "EUR") get_rate("USD", "EUR") assert provider was called once
Merge Danger
Door: two-way
The cache only lives in memory, with nothing persisted and no schema change. To roll back, revert the commit.
Blast Radius: checkout
- Stale rates: prices can use a rate up to 5 minutes old. Confirm that's acceptable for checkout pricing.
- Per-process cache: each worker keeps its own cache. Provider calls per 5 minutes are roughly workers × currency pairs, so the limit could still be reached with many workers.
- No size limit or eviction: this is fine for a fixed set of currency pairs.
- No locking: two requests that miss the cache at the same moment can both call the provider. The only cost is an extra request.
- Test isolation:
_cacheis module-level, so it carries over between tests unless a fixture clears it.
- **No `GLOSSARY.md`:** the repo doesn't have one, so I used the wording from your context and the code.
- **Check this before merging:** `test_get_rate_returns_quote` already caches `USD:EUR`. If nothing clears `_cache` between tests, the new test should see 0 provider calls and fail. Since it passes, the `mock_get` fixture probably resets the cache, but I couldn't see the fixture to confirm. If it doesn't, the test result depends on the order tests run in, and I'd add an autouse fixture that calls `_cache.clear()`.
Real run recorded with claude-code / claude-opus-5-5. Output is shown verbatim, unmodified. The only change: the trial machine's temp-folder path was replaced with a generic placeholder.
它做什么
写出审查者能快速看完的 Pull Request 描述,分三部分。
工作方式
- Summary: 用最小的图示把重点讲清楚,可以是伪代码、调用树、组件树、文件树、Mermaid 图或 diff 草图,放在它所支撑的那段短文字旁边。
- Evidence: 具体的前后对比。改动是视觉层面的,截图最好;否则给出现在由失败变成通过的那条测试。
- Merge Danger: 这次改动是单向门还是双向门(能不能回滚),以及影响范围,比如布局偏移、对调用方的破坏。
- 省略开场白,行文简短;如果仓库有
GLOSSARY.md,就用它的术语。
适合场景
审查者需要看清改了什么、风险多大的 Pull Request。
需要了解
我们试用时,它还指出了一处光看 diff 无法确认的风险(测试之间的隔离问题),而不是把它藏起来。
纯指令文件:没有脚本、不联网。 Summary 一节里的图示清单改编自 Dex Horthy(HumanLayer,MIT 协议)的 show-me skill;压缩包里附有该协议文件 LICENSE-show-me 和 CREDITS.md 说明。 它只写文字,不会运行 git,也不会替你创建 Pull Request。 压缩包里另有原仓库的 MIT 协议文件 LICENSE 和 agents/openai.yaml(供 Codex 使用的显示名)。