Skip to content

Crc/enh#1352

Merged
0utkarsh merged 2 commits into
mainfrom
crc/enh
Jun 15, 2026
Merged

Crc/enh#1352
0utkarsh merged 2 commits into
mainfrom
crc/enh

Conversation

@RitoBose

@RitoBose RitoBose commented Jun 12, 2026

Copy link
Copy Markdown

Type of Change

  • Bugfix
  • New feature
  • [ x] Enhancement
  • Refactoring
  • Dependency updates

Description

Crc/enh

Additional Changes

  • This PR modifies the database schema (database migration added)
  • This PR modifies dhall configs/environment variables

Motivation and Context

How did you test it?

Checklist

  • I formatted the code and addressed linter errors ./dev/format-all-files.sh
  • I reviewed submitted code
  • I added unit tests for my changes where possible
  • I added a CHANGELOG entry if applicable

Summary by CodeRabbit

  • New Features
    • Added asynchronous CRC verification support to the verification interface, enabling faster, non-blocking CRC checks.
    • Verification dispatch now routes CRC verification requests to the configured verification provider when supported, with clear handling when not implemented.

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@RitoBose, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 58 minutes and 42 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: dece9cae-53cf-4d3e-b656-758acff67b22

📥 Commits

Reviewing files that changed from the base of the PR and between 28e5143 and 0c93a7a.

📒 Files selected for processing (1)
  • lib/mobility-core/src/Kernel/External/Verification/Interface.hs

Walkthrough

This PR adds two service interface enhancements: updated imports in ChallanSearch for service type support, and a new async CRC verification dispatcher in Verification that delegates to the Idfy provider with fallback error handling.

Changes

External Service Interface Enhancements

Layer / File(s) Summary
ChallanSearch Interface Imports
lib/mobility-core/src/Kernel/External/ChallanSearch/Interface.hs
Updated module imports to include ChallanSearchService from types and adjusted Kernel.Types.Error and Kernel.Utils.Common imports.
Verification Async CRC Dispatcher
lib/mobility-core/src/Kernel/External/Verification/Interface.hs
Added verifyCRCAsync export and function that dispatches async CRC verification to Idfy.verifyCRCAsync for Idfy-configured services and returns InternalError "Not Implemented!" for other service variants.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • khuzema786
  • bytedex
  • RitikaHanish

Poem

🐰 A dispatcher hops to Idfy with grace,
While imports gather in their rightful place,
Two interfaces bloom in Haskell's domain,
Async verifications dance through the chain! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Crc/enh' is extremely vague and generic, using non-descriptive terminology that fails to convey meaningful information about the changeset. Revise the title to be more descriptive and specific. For example: 'Add verifyCRCAsync dispatcher to Verification interface' or 'Implement async CRC verification support'.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch crc/enh

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
lib/mobility-core/src/Kernel/External/ChallanSearch/Interface.hs (1)

20-25: 🏗️ Heavy lift

Consider NonEmpty for compile-time safety.

The function accepts [ChallanSearchService] and validates non-empty at runtime (line 27). Using NonEmpty ChallanSearchService would enforce the non-empty constraint at the type level, eliminating the runtime check and preventing invalid calls at compile time.

♻️ Proposed signature with NonEmpty
+import Data.List.NonEmpty (NonEmpty)
+
 getPendingChallanCountWithFallback ::
   (EncFlow m r, CoreMetrics m, MonadFlow m, Log m, HasRequestId r, MonadReader r m) =>
   (ChallanSearchService -> m ChallanSearchServiceConfig) ->
-  [ChallanSearchService] ->
+  NonEmpty ChallanSearchService ->
   PendingChallanReq ->
   m PendingChallanResp

Then remove the runtime check at line 27.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/mobility-core/src/Kernel/External/ChallanSearch/Interface.hs` around
lines 20 - 25, Change the signature of getPendingChallanCountWithFallback to
accept NonEmpty ChallanSearchService instead of [ChallanSearchService] (import
Data.List.NonEmpty or qualified NonEmpty) and update all call sites accordingly
so callers must provide a non-empty list; then remove the runtime non-empty
validation inside getPendingChallanCountWithFallback (the check at line 27)
because the NonEmpty type guarantees at-compile-time that at least one
ChallanSearchService exists. Ensure any pattern matches or folds over the
services use NonEmpty constructors/functions (e.g., toList, head, NE.nonEmpty
helpers) as needed.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@lib/mobility-core/src/Kernel/External/ChallanSearch/Interface.hs`:
- Line 21: The signature for getPendingChallanCountWithFallback includes a
redundant MonadFlow m constraint because EncFlow m r (i.e., HasFlowEnv) already
implies MonadFlow (and thus TryException) which withTryCatch needs; remove
MonadFlow m from the constraint list and keep EncFlow m r, CoreMetrics m, Log m,
HasRequestId r, MonadReader r m (and any required TryException bound is already
satisfied via EncFlow/HasFlowEnv).

---

Nitpick comments:
In `@lib/mobility-core/src/Kernel/External/ChallanSearch/Interface.hs`:
- Around line 20-25: Change the signature of getPendingChallanCountWithFallback
to accept NonEmpty ChallanSearchService instead of [ChallanSearchService]
(import Data.List.NonEmpty or qualified NonEmpty) and update all call sites
accordingly so callers must provide a non-empty list; then remove the runtime
non-empty validation inside getPendingChallanCountWithFallback (the check at
line 27) because the NonEmpty type guarantees at-compile-time that at least one
ChallanSearchService exists. Ensure any pattern matches or folds over the
services use NonEmpty constructors/functions (e.g., toList, head, NE.nonEmpty
helpers) as needed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 29808e32-450d-4dea-8b26-0b4c648eb998

📥 Commits

Reviewing files that changed from the base of the PR and between c72fffc and 048c8b5.

📒 Files selected for processing (2)
  • lib/mobility-core/src/Kernel/External/ChallanSearch/Interface.hs
  • lib/mobility-core/src/Kernel/External/Verification/Interface.hs

SignzyChallanSearch cfg -> CIS.signzyChallanSearch cfg req

getPendingChallanCountWithFallback ::
(EncFlow m r, CoreMetrics m, MonadFlow m, Log m, HasRequestId r, MonadReader r m) =>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Find the type signature of withTryCatch and TryException class definition

# Search for withTryCatch type signature
rg -n -A 2 'withTryCatch\s*::' --type=hs

# Search for TryException typeclass definition
rg -n -A 5 'class.*TryException' --type=hs

Repository: nammayatri/shared-kernel

Length of output: 734


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Inspect the function and where withTryCatch is used in Interface.hs
sed -n '1,120p' lib/mobility-core/src/Kernel/External/ChallanSearch/Interface.hs | cat -n

# Show the full TryException definition
sed -n '1,120p' lib/mobility-core/src/Kernel/Types/TryException.hs | cat -n

# Locate MonadFlow definition and inspect its constraints
rg -n --type=hs "class\s+MonadFlow\b|type\s+MonadFlow\b|MonadFlow\s+m" lib/mobility-core/src/Kernel lib/mobility-core/src | head -n 50

# If a file is found, print likely definition area(s)
# (Fallback: directly search likely patterns)
file="$(rg -n --type=hs -l "class\s+MonadFlow\b" lib/mobility-core/src/Kernel lib/mobility-core/src | head -n 1 || true)"
if [ -n "${file}" ]; then
  echo "---- MonadFlow file: ${file} ----"
  sed -n '1,160p' "$file" | cat -n
fi

Repository: nammayatri/shared-kernel

Length of output: 8289


🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n --type=hs "class\s+MonadFlow\b|type\s+MonadFlow\b" lib/mobility-core/src/Kernel | head -n 50

# Also search in other likely dirs for the MonadFlow definition
rg -n --type=hs "class\s+MonadFlow\b|type\s+MonadFlow\b" lib/mobility-core/src | head -n 50

# Find where TryException is used with MonadFlow (maybe MonadFlow extends it)
rg -n --type=hs "TryException\s+m|TryException\b" lib/mobility-core/src/Kernel/Types lib/mobility-core/src/Kernel | head -n 80

Repository: nammayatri/shared-kernel

Length of output: 8786


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Show MonadFlow definition in Kernel/Types/App.hs (around the referenced line)
sed -n '1,120p' lib/mobility-core/src/Kernel/Types/App.hs | cat -n

# Show TryException instance for FlowR in Kernel/Types/Flow.hs (around the referenced line)
sed -n '240,320p' lib/mobility-core/src/Kernel/Types/Flow.hs | cat -n

# Show imports/instances nearby in TryException for completeness
sed -n '1,120p' lib/mobility-core/src/Kernel/Types/TryException.hs | cat -n

# Show full relevant signature context in Interface.hs (around withTryCatch usage)
sed -n '1,90p' lib/mobility-core/src/Kernel/External/ChallanSearch/Interface.hs | cat -n

Repository: nammayatri/shared-kernel

Length of output: 10212


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Find EncFlow definition
enc_file="$(rg -n --type=hs "type\s+EncFlow|class\s+EncFlow" lib/mobility-core/src/Kernel | head -n 1 | cut -d: -f1 || true)"
echo "EncFlow file: ${enc_file:-<not found>}"
if [ -n "${enc_file:-}" ]; then
  sed -n '1,200p' "$enc_file" | cat -n
fi

# Inspect Kernel.Types.Common for relevant constraints (if EncFlow not found above)
if [ -z "${enc_file:-}" ]; then
  rg -n --type=hs "EncFlow\s+m" lib/mobility-core/src/Kernel/Types lib/mobility-core/src/Kernel | head -n 50
fi

# Inspect Kernel.Prelude reexports for withTryCatch/logDebug/throwError if available
rg -n --type=hs "withTryCatch|logDebug|throwError" lib/mobility-core/src/Kernel/Prelude lib/mobility-core/src/Kernel | head -n 80

Repository: nammayatri/shared-kernel

Length of output: 18190


🏁 Script executed:

#!/bin/bash
set -euo pipefail

rg -n --type=hs "module Kernel\.Types\.Common|EncFlow\s" lib/mobility-core/src/Kernel/Types/Common.hs

sed -n '1,140p' lib/mobility-core/src/Kernel/Types/Common.hs | cat -n

# Check whether Interface.hs brings EncFlow from Kernel.Types.Common or another import
rg -n --type=hs "EncFlow" lib/mobility-core/src/Kernel/External/ChallanSearch/Interface.hs

Repository: nammayatri/shared-kernel

Length of output: 6084


MonadFlow m constraint is redundant in getPendingChallanCountWithFallback.

EncFlow m r expands to HasFlowEnv m r ..., and HasFlowEnv already requires MonadFlow m (which includes TryException m). Since withTryCatch needs TryException m, you can drop MonadFlow m from the signature.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/mobility-core/src/Kernel/External/ChallanSearch/Interface.hs` at line 21,
The signature for getPendingChallanCountWithFallback includes a redundant
MonadFlow m constraint because EncFlow m r (i.e., HasFlowEnv) already implies
MonadFlow (and thus TryException) which withTryCatch needs; remove MonadFlow m
from the constraint list and keep EncFlow m r, CoreMetrics m, Log m,
HasRequestId r, MonadReader r m (and any required TryException bound is already
satisfied via EncFlow/HasFlowEnv).

@0utkarsh 0utkarsh merged commit 5115641 into main Jun 15, 2026
2 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

Development

Successfully merging this pull request may close these issues.

3 participants