Skip to content

chore: restore edstem update, retry rate limits, and drop dead code - #13

Merged
bunizao merged 7 commits into
mainfrom
chore/cleanup-update-retry
Sep 19, 2026
Merged

bunizao merged 7 commits into
mainfrom
chore/cleanup-update-retry

Conversation

@bunizao

@bunizao bunizao commented Sep 19, 2026

Copy link
Copy Markdown
Owner

Cleanup pass over the CLI and Ed client: the promised edstem update command, read retries, one fewer /api/user round trip, a dead module removed, and a usable edstem-mcp --help.

Changes

  • edstem update: src/update.ts was dead code despite CHANGELOG 0.3.1 promising the command. It is now a top-level mutating command. --check reports {currentVersion, latestVersion, updateAvailable, upgradeCommand}; without it, an available update is confirmed through the usual plan/--yes/--dry-run flow and then installed with npm install -g edstem-cli@latest. mutationAction no longer builds an Ed client, so updating does not require a token.
  • Retry on rate limits: EdClient.request retries GET on 429/502/503/504 with exponential backoff (retryBaseDelayMs * 2^attempt), honoring a larger Retry-After header, up to maxRetries. POST and PUT are never retried. loadConfig now reads the rateLimit.maxRetries and rateLimit.retryBaseDelay block that config.yaml already declared, wired through the CLI runtime and the stdio MCP server. The unused requestDelay and maxCount keys were dropped from config.yaml.
  • Memoized identity lookup: fetchUser() caches per client instance for 60 seconds and shares an in-flight promise; a failed fetch is not cached. resolveCourseId plus the command that follows it used to hit /api/user twice.
  • Removed src/ed/serialization.ts (and its test). src/ed/projections.ts replaced it; nothing else imported it.
  • edstem-mcp --help / --version now print usage and the version instead of silently starting a stdio server that hangs in a terminal.

Tests

npm run check, npm run test:node (82 passing), npm run build:local, npm run skill:generate all clean; SKILL.md regenerated for the new command.

New coverage: update --check and --dry-run against a mocked registry with spawnSync asserted unused, the confirmed install path, retry behaviour (429 then 200, Retry-After honored, POST not retried, give-up after maxRetries) via the injected sleep, rateLimit config parsing, and the fetchUser memo (shared call, TTL expiry with fake timers, failure not cached). No request ever reaches the real Ed API.

Copilot AI lite review requested due to automatic review settings September 19, 2026 09:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 19, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
edstem-mcp 14dba40 Commit Preview URL

Branch Preview URL
Sep 19 2026, 11:08 AM

Wire src/update.ts into a top-level mutating command that reports the npm
registry version and upgrades when one is available. mutationAction no
longer builds an Ed client, so update runs without a token.
GET requests now retry on 429/502/503/504 with exponential backoff and an
honored Retry-After header. Writes are never retried. loadConfig reads the
rateLimit block that config.yaml already declared.
resolveCourseId and the commands that follow it each hit /api/user. Share one
in-flight promise per client and cache the result briefly; failures are not
cached.
src/ed/projections.ts replaced it; only its own test imported it.
edstem-mcp used to start a stdio server for any argument, so --help hung in a
terminal.
Also report the command that ran instead of a derived boolean.
@bunizao
bunizao force-pushed the chore/cleanup-update-retry branch from cb0130a to 14dba40 Compare September 19, 2026 11:07
@bunizao
bunizao merged commit d653cf1 into main Sep 19, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants