feat: decompose index.js routes (#744), daily streaks (#947), range-proof stub (#940), view-key stub (#943) - #1085
Merged
joelpeace48-cell merged 2 commits intoJul 29, 2026
Conversation
…b range proofs and view keys - FinesseStudioLab#744: Extract health/observability routes (GET /health, /ready, /health/rpc, /health/indexer, GET /metrics) into backend/src/routes/health.js as a createHealthRoutes() factory accepting rpcPool, metrics, eventIndexer, etc. Extract admin API-key management (create/list/revoke/rotate/rate-tier) into backend/src/routes/adminKeys.js as createAdminKeyRoutes(). Both modules are drop-in mounts for index.js wiring. Unit tests: routes/health.test.js (9 cases covering healthy/degraded/shutdown/metrics content). - FinesseStudioLab#947: Add backend/src/services/streakService.js — createStreakService() tracks consecutive UTC-day activity per identity, applies escalating point bonuses (10/15/25/50 pts at day 1/3/7/14 thresholds), enforces one-credit-per-day anti-abuse, and accumulates total points. Add backend/src/routes/streaks.js with POST/:identity/activity, GET/:identity, DELETE/:identity (admin reset). Unit tests: services/streakService.test.js (16 cases across all code paths). - FinesseStudioLab#940: Add docs/RANGE_PROOFS.md — design stub with Bulletproofs approach, verify_range_proof() API surface, threat model table, and acceptance criteria. - FinesseStudioLab#943: Add docs/SELECTIVE_DISCLOSURE.md — design stub with HKDF-derived per-record view keys, scoped disclosure package format, threat model, and acceptance criteria. Closes FinesseStudioLab#744, Closes FinesseStudioLab#940, Closes FinesseStudioLab#943, Closes FinesseStudioLab#947
joelpeace48-cell
merged commit Jul 29, 2026
f6419be
into
FinesseStudioLab:main
5 of 16 checks passed
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
Backend: Decompose monolithic
index.js(~1450 lines) into route/service/repository layers #744 — Begin decomposing the monolithicbackend/src/index.js. Extracted two self-contained modules:backend/src/routes/health.js—createHealthRoutes()factory encapsulatingGET /health,/ready,/health/rpc,/health/indexer, andGET /metrics. All dependencies (rpcPool, metrics, eventIndexer, jobRunner, etc.) are injected; index.js becomes pure wiring for these endpoints.backend/src/routes/adminKeys.js—createAdminKeyRoutes()factory withPOST/GET/DELETE /admin/api-keysandPUT /admin/api-keys/:id/rotate|rate-tier. Handles validation, audit logging, and error responses; index.js passesapiKeyRepository+ middleware.routes/health.test.js(9 cases: healthy/degraded states, cache hit, shutdown detection, indexer null, metrics content/format).Daily streaks and login rewards #947 — Daily streak tracking and login rewards:
backend/src/services/streakService.js—createStreakService()tracks consecutive UTC-day activity per identity, applies escalating point bonuses (10/15/25/50 pts at day 1/3/7/14 thresholds), enforces one-credit-per-day anti-abuse, and accumulates lifetime total points. Streak resets on any missed calendar day.backend/src/routes/streaks.js—POST /:identity/activity(record login/activity),GET /:identity(read current streak),DELETE /:identity(admin reset). ReturnsalreadyCredited: truewhen called multiple times on the same day.services/streakService.test.js— 16 cases covering all thresholds, day boundaries, same-day deduplication, cross-day accumulation, reset, and multi-identity isolation.Range-proof library for confidential reward amounts #940 —
docs/RANGE_PROOFS.md: design stub defining the Bulletproofs-based approach,verify_range_proof()API surface, threat model (forgery, replay, overflow), and acceptance criteria for the on-chain implementation.Selective disclosure / view keys for compliance #943 —
docs/SELECTIVE_DISCLOSURE.md: design stub defining per-record HKDF-derived view keys, scoped disclosure package format (record_id, expires_at, authorized_to, user signature), threat model (scope creep, forged packages, expiry bypass), and acceptance criteria.Test plan
cd backend && npx vitest src/routes/health.test.js— 9 health route tests passcd backend && npx vitest src/services/streakService.test.js— 16 streak service tests passCloses #744, Closes #940, Closes #943, Closes #947