Skip to content

perf(cli): isolate leaderboard calculation - #205

Merged
es3n1n merged 6 commits into
otter-sec:mainfrom
rexdotsh:perf/issue-190-leaderboard-calculation
Aug 14, 2026
Merged

perf(cli): isolate leaderboard calculation#205
es3n1n merged 6 commits into
otter-sec:mainfrom
rexdotsh:perf/issue-190-leaderboard-calculation

Conversation

@rexdotsh

@rexdotsh rexdotsh commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Split leaderboard calculation from database query and hydration logic.
  • Extract score-provider initialization into a narrow module.
  • Extract shared challenge query predicates from the broader challenge service.

Part of #190.

Motivation

The seed command only needs leaderboard calculation and score-provider functionality, but its imports previously traversed broad API service and provider barrels. This pulled unrelated provider SDKs and services into the seed dependency graph, preventing Bun from tree-shaking them.

The new module boundaries allow the seed entry point to import only what it uses.

Bundle impact

Measured from apps/cli with:

bun build src/commands/seed/index.ts --target bun --minify
Before After
Seed entry bundle 3,174,547 bytes 941,101 bytes

This is a reduction of approximately 70%. AWS SDK, Nodemailer, and Google Cloud dependencies are no longer included in the seed graph.

This PR does not materially reduce the complete CLI bundle yet. Other CLI entry points still import the full provider barrel; those will be handled separately.

Behavior

Leaderboard query and calculation logic is unchanged; this is a module-boundary refactor.

Score-provider configuration is now validated when the scoring module is loaded rather than whenever the general provider barrel is imported. The API server continues to load it during startup through the leaderboard workers.

Verification

  • Workspace typecheck passes.
  • oxlint --deny-warnings passes.
  • Server suite passes: 630 tests across 54 files.
  • No stale imports of the removed leaderboard service remain.

@rexdotsh
rexdotsh requested a review from es3n1n as a code owner August 2, 2026 14:05
@rexdotsh rexdotsh mentioned this pull request Aug 2, 2026

@devin-ai-integration devin-ai-integration Bot 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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@rexdotsh

rexdotsh commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

also - this is just a start, have some other changes lined up that would shrink the entire CLI, but thought i'd split em up to make it easier for you to review

@es3n1n es3n1n left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

since you moved the score provider to score.ts, maybe it would make sense to split all of them like this? probably in a new subfolder in providers though

@es3n1n

es3n1n commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

sorry for the delays in my response, i was out of office this entire time 🙃

i will do a more thorough review later on this week

@rexdotsh

Copy link
Copy Markdown
Contributor Author

since you moved the score provider to score.ts, maybe it would make sense to split all of them like this? probably in a new subfolder in providers though

yeah agreed, that's where the rest of the changes were also headed. i was thinking in providers/instances/? i think a followup PR for this might be better, or lmk, i can do it directly in this PR as well.

sorry for the delays in my response, i was out of office this entire time 🙃

i will do a more thorough review later on this week

no worries! hope you had fun at defcon :) (so much fomo lol)

@es3n1n

es3n1n commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

yeah agreed, that's where the rest of the changes were also headed. i was thinking in providers/instances/? i think a followup PR for this might be better, or lmk, i can do it directly in this PR as well.

do you want to try these new github stacked prs for this?

@rexdotsh

Copy link
Copy Markdown
Contributor Author

yeah agreed, that's where the rest of the changes were also headed. i was thinking in providers/instances/? i think a followup PR for this might be better, or lmk, i can do it directly in this PR as well.

do you want to try these new github stacked prs for this?

that'd be great but seems like it's not possible to do stacked PRs across different repos... since i’m sending these PRs from my fork, i think we could only use that if i had collaborator access here.

https://docs.github.com/en/pull-requests/get-started/about-stacked-prs#where-can-you-use-stacked-pull-requests

@es3n1n

es3n1n commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

oof yeah, i see. makes sense.

you can just add these changes to this pr then i think

@rexdotsh
rexdotsh force-pushed the perf/issue-190-leaderboard-calculation branch from 123fcf5 to 844eb58 Compare August 12, 2026 22:58
@rexdotsh

Copy link
Copy Markdown
Contributor Author

oof yeah, i see. makes sense.

you can just add these changes to this pr then i think

yeah, all done

@devin-ai-integration devin-ai-integration Bot 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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@es3n1n
es3n1n merged commit c54549e into otter-sec:main Aug 14, 2026
18 checks passed
@es3n1n

es3n1n commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Thank you!

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