feat(core): Discord REST caching proxy — poller, cache, HTTP server#9
Merged
Conversation
Implements the core proxy: a single poller fetches channels and messages from Discord on a configurable interval, stores them in an in-memory cache with snowflake-based eviction (4h window), and serves them via Discord-compatible REST endpoints. Key decisions: - `after` parameter required on messages endpoint (prevents full-history dumps) - Cache TTL = poll interval × 1.5 for staleness tracking - X-Cache header reports HIT/STALE based on TTL freshness - Input validation on `after` (must be numeric snowflake) and `limit` (positive int) - Injectable fetch in Discord client for testability 44 tests across 5 files, 110 assertions. Closes #3 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
Implements the core of scream-hole: a single poller fetches channels and messages from Discord on a configurable interval, stores them in an in-memory cache with snowflake-based eviction, and serves them via Discord-compatible REST endpoints.
Changes
Retry-After: 0handling)/health,/api/v10/guilds/{id}/channels,/api/v10/channels/{id}/messageswithafterrequired,limitvalidation,X-CacheHIT/STALE headerscacheTtlMs(poll × 1.5) andcacheWindowMs(4h default)Test Plan
bun test— 44 pass, 0 fail, 110 assertionsbunx tsc --noEmit— cleanbun run lint— cleanCloses #3
🤖 Generated with Claude Code