Skip to content

Feature/score bounds 1197#1275

Open
warisu wants to merge 3 commits into
LabsCrypt:mainfrom
warisu:feature/score-bounds-1197
Open

Feature/score bounds 1197#1275
warisu wants to merge 3 commits into
LabsCrypt:mainfrom
warisu:feature/score-bounds-1197

Conversation

@warisu

@warisu warisu commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

📝 Pull Request Summary [Wave 200pts]

Description

This PR addresses Issue #1197, hardening database integrity bounds by introducing a strict database CHECK constraint enforcing the standard 300–850 scoring index.

Key Modifications

  • Idempotent Data Backfill: Added a transactional preprocessing batch script in the migration path to clean and clamp legacy database entries ahead of time.
  • Database Contraband Guards: Attached the chk_score_range constraint via raw migration commands to reject stray manual modifications or query bugs trying to commit anomalous numbers.
  • Service Boundary Sync: Confirmed application query scripts map to the structural constraint cleanly without disrupting operational code execution.

Target Branch: main
Closes #1197

@ogazboiz

ogazboiz commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

conflicting with main (it touches the initial-schema migration + scoresService, which have both moved), please rebase and i'll review the score-bounds logic and the requestLogger changes: git fetch origin && git rebase origin/main && git push --force-with-lease.

one thing to reconsider while you're in there: this edits backend/migrations/1771691269865_initial-schema.js, the initial migration that's already been applied in every environment. schema changes should almost always be a NEW migration rather than an edit to an applied one (editing it won't re-run anywhere it's already applied). worth splitting the score-bounds schema change into its own new migration.

if you want to keep contributing, join us on Telegram: https://t.me/+DOylgFv1jyJlNzM0

@ogazboiz ogazboiz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the score-clamping idea is good but there are a few real issues to fix:

  1. don't edit the already-applied migration. you appended a CHECK-constraint block to backend/migrations/1771691269865_initial-schema.js, which is already applied everywhere, so that changes its checksum (why migration-check is red) and it won't re-run. move the constraint into a NEW migration, e.g. 1771691269867_score-range-check.js, and revert the initial-schema file.
  2. that appended block also uses commonjs exports.up/exports.down grafted onto a file that already has esm export const up/down, so it's duplicate/conflicting definitions that won't run, write the new migration in the repo's esm style.
  3. real bug in scoresService.ts (around lines 31-36): Array.from({length}, fn1, fn2) is called with TWO mapper arrows, and the second is silently swallowed as thisArg (looks like a bad merge). it should be a single mapper.
  4. scope: changing the prod default log level from info to http (logger.ts) doesn't belong in a score-bounds pr, pull it out.
  5. prettier fails, several files end without a trailing newline, run prettier --write.

also it's conflicting with main, so rebase after the above. fix 1-3 and it's real progress.

if you want to keep contributing, join us on Telegram: https://t.me/+DOylgFv1jyJlNzM0

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.

[Backend] scores table has no CHECK constraint enforcing the 300-850 range the app clamps in SQL

2 participants