Skip to content

Feat/rsk 25 connecting assessment to rule engine - #23

Merged
AliJohari05 merged 4 commits into
mainfrom
feat/RSK-25-connecting-assessment-to-rule-engine
Nov 21, 2026
Merged

AliJohari05 merged 4 commits into
mainfrom
feat/RSK-25-connecting-assessment-to-rule-engine

Conversation

@MParsa-ES

Copy link
Copy Markdown
Owner

Jira Issue & User Story

  • Jira Ticket: RSK-25
  • User Story: US-01B

Summary of Changes

  • Rule Evaluation Engine (assessments/engine.py, rules/selectors.py): Connected POST /api/v1/risk-assessments to active RiskRule records (enabled=True and effective_at <= evaluated_at), evaluating AMOUNT_LIMIT and BLOCKLIST rules with strict severity aggregation (REJECT > REVIEW > APPROVE) and immutable DecisionReason snapshots (rule_id, rule_revision, rule_snapshot).
  • Idempotency Persistence (assessments/models.py, assessments/views.py): Added AssessmentCreateRequest with row-level locking to replay 201 Created responses for identical (Idempotency-Key, actor, payload) retries and return 409 IDEMPOTENCY_KEY_REUSED on key reuse with a different payload or caller.
  • S2-LDG Ledger Integration (assessments/services.py): Wired assess_ledger_history using Asia/Tehran daily boundaries (GEN-05) to evaluate cumulative daily limits and safely escalate ACCOUNT_NOT_FOUND / LEDGER_UNAVAILABLE signals to REVIEW.
  • Contract & Test Hygiene (openapi/s4_rsk.yaml, assessments/serializers.py, conftest.py): Synchronized RiskAssessmentRequest and RiskAssessmentDetail schemas for INTERNAL/EXTERNAL transfers, fixed StrictPositiveInt64Field OpenAPI min/max bounds, isolated test runs from .env neighbor URLs, and added unit, integration, contract, and concurrency tests.

LabBank Technical Standards Checklist

  • GEN-01 / GEN-02: Endpoint is under /api/v1/ and documented with OpenAPI (drf-spectacular).
  • GEN-03: Money fields use 64-bit integer (BigIntegerField) in IRR (no float/double).
  • GEN-04: Public identifiers use UUIDv7 (uuid6.uuid7).
  • GEN-05: Timestamps are stored/returned in UTC; daily boundaries use Asia/Tehran.
  • GEN-06: Errors return RFC 9457 application/problem+json format.
  • GEN-07 / GEN-08: Mutating POST endpoints support Idempotency-Key and propagate X-Correlation-ID.
  • Tests: Unit and integration tests (pytest) added and passing.

@AliJohari05 AliJohari05 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.

I review everything.
No issue exists

@AliJohari05
AliJohari05 merged commit b6669d7 into main Nov 21, 2026
1 check passed
@AliJohari05
AliJohari05 deleted the feat/RSK-25-connecting-assessment-to-rule-engine branch November 21, 2026 19:11
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