fix: apply PR cache in daemon hot paths to prevent rate-limit exhaustion#431
Open
fix: apply PR cache in daemon hot paths to prevent rate-limit exhaustion#431
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
LookupInfoWithClientandLookupInfoByURLcache-aware ininternal/pr/cache.goby loading/saving cache entries, honoringcacheHitTTL/cacheMissTTL, and applyingcacheMinFetchInterval.LookupInfoCached,LookupInfoByURLCached) and switch daemon hot paths to them ininternal/daemon/monitor.go,internal/daemon/types.go, andinternal/daemon/proto_handler.go..semgrep/architecture.yamlsection 11 so architecture lint now enforces this path directly.Verification
go test ./internal/pr/...✅go test ./internal/daemon/...✅go test -count=1 ./internal/pr/... ./internal/daemon/...✅make lint✅ (0 findings)Acceptance Criteria Evidence
LookupInfo / LookupInfoByURL use cache + TTL/min interval
internal/pr/cache.govia cache read/write helpers and min-fetch gating.TestLookupInfoWithClient_MustUseCacheTestLookupInfoWithClient_CacheHitSkipsAPITestLookupInfoByURL_MustUseCacheTestLookupInfoByURL_CacheHitSkipsAPIcheckPRMergedWithURL throttled (not every 5s API call)
internal/daemon/monitor.gonow calls cached wrappers only.pr.LookupInfo*calls remain in daemon package; semgrep architecture rule enforces this.lookupPRInfo in types.go uses cached data
internal/daemon/types.gonow routes throughLookupInfoCached/LookupInfoByURLCached.Consider global rate limiter
20 active runs under 3000 calls/hr
cacheMissTTL=30s:20 runs * (3600/30) = 2400 calls/hr(below 3000/hr target).No regression to existing cache TTL constants / PopulateRunInfo
PopulateRunInfopath still passes regression tests ininternal/pr/cache_test.go.All new TDD tests pass
go test ./internal/pr/....Semgrep exclusions removed
monitor.go,types.go,proto_handler.goin.semgrep/architecture.yamlsection 11.make lintwith 0 findings.Refs: orch-450