You are working on the hyperswitch repository (Rust payment processing system).…
- User
You are working on the hyperswitch repository (Rust payment processing system).
REPOSITORY SETUP:
- Repository: juspay/hyperswitch
- Working directory: ./repos/hyperswitch_pool_8 (already cloned)
- Base commit: 776bde00efce8be35e0c63c1bdc6215921babddf
- Task ID: juspay__hyperswitch-7870
- Version: v1.113.0
TASK DESCRIPTION: Bug: Add support for caching and resolving last used lineage context
Currently, after a user logs in and switches between merchants or profiles, their context is not remembered across sessions.
Each new login resolves the default role from the DB and starts with a clean slate.This leads to:
- Poor user experience for users with multiple roles
- Repetitive DB queries for every login
- No continuity across logins for previously active merchant/profile context
Objective
Introduce a mechanism to cache the last used lineage context (
org_id,merchant_id,profile_id,role_id,tenant_id) in Redis and use it for JWT generation on subsequent logins.Expected Behavior
- During login:
- If lineage context exists in Redis → use it to validate and generate the JWT.
- If not found or invalid → fallback to default DB-based user role resolution.
- During merchant/profile switch:
- Store the latest lineage context in Redis for future use.
- Redis entries should have a TTL of 7 days to auto-expire for inactive users.
DETAILED CONTEXT & HINTS:
Type of Change
- Bugfix
- New feature
- Enhancement
- Refactoring
- Dependency updates
- Documentation
- CI/CD
Description
This PR introduces lineage context caching to enhance login and account-switch flows with better continuity and reduced DB load.
Key Changes
Assistant
I'll implement the lineage context caching feature for the Hyperswitch repository. Let me start by understanding the codebase structure and identifying the relevant files for login and context management.
First, I'll explore the repository structure to locate authentication and context-related code:
Assistant
Let me examine the login flow and context management more closely, particularly looking at user authentication and the areas where lineage context would need to be implemented.
Assistant
(no content)
Assistant
Now let me examine the core user authentication logic to understand how login currently works:
Assistant
Let me search for the signin function specifically to understand how login currently works:
Assistant
(no content)
Assistant
(no content)
Assistant
Let me also look at the switch functions to understand how lineage context is managed during switches:
Assistant
Let me look at the authentication structures to understand how tokens and lineage are handled:
Assistant
Let me look for lineage context definitions and Redis integration:
Assistant
Let me search for the domain structure to understand the user roles and authentication flow better:
Assistant
(no content)
Assistant
(no content)
Assistant
Let me search for existing Redis integration or similar caching patterns in the codebase:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.