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 使用的顯示名稱)。