Skip to content

fix(backend): resolve assigned policy and security issues - #799

Merged
nonsobethel0-dev merged 4 commits into
Parashield-Protocol:mainfrom
codeX-james:fix/codeX-james-assigned-issues
Oct 19, 2026
Merged

nonsobethel0-dev merged 4 commits into
Parashield-Protocol:mainfrom
codeX-james:fix/codeX-james-assigned-issues

Conversation

@codeX-james

Copy link
Copy Markdown
Contributor

About this PR

This PR resolves the four open issues assigned to codeX-james. Each issue is implemented in its own commit.

Changes

#783 — Consistent claim-evaluation snapshots

  • Reads the policy and latest matching oracle reading in one interactive Prisma transaction.
  • Uses PostgreSQL REPEATABLE READ, preventing concurrent policy/oracle updates from being mixed in one decision.
  • Documents the isolation strategy.
  • Adds a concurrency-focused regression test that mutates the simulated database between reads and confirms both returned values still come from the original snapshot.

#784 — Port configuration validation

  • Validates PORT as an integer from 1 through 65535 during configuration loading and immediately before listening.
  • Defaults an omitted value to 3001 and fails startup for malformed or out-of-range values.
  • Documents the accepted range in .env.example and the README.
  • Adds boundary and invalid-value coverage.

#785 — Authenticated and anonymous rate-limit separation

  • Keeps anonymous traffic in the existing per-IP bucket and quota.
  • Places authenticated callers in independent per-wallet buckets.
  • Gives authenticated callers a five-times-higher quota while retaining endpoint-specific throttler behavior.
  • Adds tests for anonymous limits, authenticated limits, and two users sharing one IP.

#786 — Versioned premium-rate templates

  • Adds a monotonically increasing premium-rate version to products.
  • Stores immutable premiumRate and premiumRateVersion snapshots on every policy at creation.
  • Includes a migration that backfills existing policies from their linked products.
  • Increments a product's version only when its premium rate changes.
  • Documents that updates affect future quotes/policies only and adds regression tests for rate updates and snapshot immutability.

Issue Closure

Closes #783
Closes #784
Closes #785
Closes #786

Verification

DATABASE_URL=postgresql://user:pass@localhost:5432/parashield_test npx prisma validate
The schema at prisma/schema.prisma is valid 🚀

npm test -- --runInBand \
  src/common/utils/config.utils.spec.ts \
  src/common/guards/user-throttler.guard.spec.ts \
  src/policy/premium-rate-versioning.spec.ts \
  src/claims/claim-evaluation-snapshot.spec.ts

Test Suites: 4 passed, 4 total
Tests:       20 passed, 20 total
Snapshots:   0 total

Upstream baseline status

The branch was created and finally rebased from the latest upstream/main. Before any changes, the repository-wide baseline was already failing:

  • npm run build: 16 existing TypeScript errors, including duplicate implementations/imports and unresolved identifiers in oracle, policy, Stellar, and security files.
  • npm test -- --runInBand: 33 failing and 33 passing suites (452 passing tests), including the same compilation failures and unrelated existing assertion failures.
  • npm run lint: the package script references eslint, but ESLint is not present in the locked dependencies/local binary.

The same unrelated build errors remain after this scoped batch; the changed schema and new/modified issue files introduce no additional TypeScript diagnostics beyond the recorded upstream set.

@drips-wave

drips-wave Bot commented Oct 19, 2026

Copy link
Copy Markdown

@codeX-james Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@nonsobethel0-dev
nonsobethel0-dev merged commit 741c693 into Parashield-Protocol:main Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants