Skip to content

feat:Prometheus metric cardinality guard for user-controlled label va… - #708

Merged
robertocarlous merged 2 commits into
Neurowealth:mainfrom
SheyeJDev:feat/Prometheus-metric-cardinality-guard-for-user-controlled-label-values
Oct 20, 2026
Merged

robertocarlous merged 2 commits into
Neurowealth:mainfrom
SheyeJDev:feat/Prometheus-metric-cardinality-guard-for-user-controlled-label-values

Conversation

@SheyeJDev

Copy link
Copy Markdown
Contributor

Summary

Adds documentation comments to the WhatsApp user service. This is a comment-only change with no functional or behavioral differences.

Changes

  • Added doc comments to all exported types and functions, including behavior on missing users, return values, and balance clamping.
  • Added inline comments explaining the less obvious logic:
    • OTP lifecycle: when it is cleared, when it is kept on a wrong guess, and single-use consumption.
    • The yield summary's APY calculation: snapshots first, falling back to the latest protocol rates per (protocol, asset) pair.
    • The 30-day reporting window and the parallel snapshot/rate queries.
  • Labeled the test-only helpers.

Notes for reviewers

While documenting, I added NOTE comments on two existing issues. I did not fix them here:

  • generateOtp uses Math.random(), which isn't cryptographically secure. crypto.randomInt would be a safer choice.
  • verifyOtp doesn't limit failed attempts, so a 6-digit code could be brute-forced within its 5-minute TTL.

Also worth knowing: decrementBalance silently clamps to 0 on overdraw instead of throwing.

I'm happy to open follow-up PRs for these.

Testing

No code changes, so no new tests. Existing tests and the build are unaffected.

Closes #660
Closes #661
Closes #659
Closes #679

@robertocarlous
robertocarlous merged commit 16ab66f into Neurowealth:main Oct 20, 2026
3 of 5 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

2 participants