Skip to content

refactor(earn): read the environment and cluster from the scope - #2554

Open
keeganthomp wants to merge 2 commits into
mainfrom
hoo-1881-earn-read-scope
Open

keeganthomp wants to merge 2 commits into
mainfrom
hoo-1881-earn-read-scope

Conversation

@keeganthomp

@keeganthomp keeganthomp commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

What

Earn routes and services take the environment and cluster from the open cluster scope instead of passing them down, the last step of HOO-1881, after #2544.

  • Routes read currentClusterScope(), never resolveSdpEnvironment(c) or earnRuntime(c)
  • Deposit, withdraw, external-wallet, queued-withdraw, exposure and sponsorship inputs lose environment/cluster
  • earnClusterFor is gone; plan and row checks compare against the scope
  • The boundary test fails Earn code that reads either fact anywhere else

Reviewer notes

  • No behavior change: every scope holds the environment these sites passed, so idempotency fingerprints stay byte-identical (a test asserts the scope's value)
  • RPC counts unchanged on every path: no client, call or batch moved
  • Reads about one recorded row keep its environment; the URL helpers refuse a mismatch

Verification

  • API full suite on main: 495 files, 8,114 tests pass
  • 10 route tests now assert the scope a mocked service ran in
  • pnpm typecheck 28/28, Biome, module-boundary and value-movement checks pass
  • Not run: live API, devnet/mainnet calls, sdp-api-integration suites

Tier: Critical (money paths). Threat model: same callers and actions; Earn code outside a scope fails closed (CLUSTER_SCOPE_MISSING). AI use: written with Claude Code.

🤖 Generated with Claude Code

- Routes and services stop threading what the cluster scope holds
  (ADR 0007); earnClusterFor and the route-bound earnRuntime(c) go
- The boundary test fails Earn code that reads either fact elsewhere

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
sdp-docs Ready Ready Preview Oct 24, 2026 12:28pm UTC
sdp-web Ready Ready Preview Oct 24, 2026 12:28pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Critical impact] The PR appears safe to merge.

Summary

Earn routes and services now read their environment and cluster from currentClusterScope() instead of passing them through service inputs.

  • Earn routes and services take their environment and cluster from the open project scope.

Reviews (2) · Last reviewed commit: "refactor(earn): read the scope inside th..." · Reviewed by Greptile

Comment thread apps/sdp-api/src/services/earn/vault-external-wallet.service.ts Outdated
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@keeganthomp

Copy link
Copy Markdown
Contributor Author

@greptileai review

This branch was successfully deployed

2 active deployments
Preview – sdp-web — 2da29325 Deployed Oct 24, 2026 by vercel[bot]
Preview – sdp-docs — 2da29325 Deployed Oct 24, 2026 by vercel[bot]
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.

1 participant