feat: add cryptographic conflict resolution engine for offline sync queues#619
Merged
Nitya-003 merged 4 commits intoJul 7, 2026
Merged
Conversation
|
@Neelr1912 is attempting to deploy a commit to the Nitya Gosain's projects Team on Vercel. A member of the Team first needs to authorize it. |
- Resolve SyncStatusIndicator.tsx merge conflict between feature/conflict-resolution-engine and main: keep all conflict- detection state & ConflictResolutionModal integration from the PR while using i18n t() calls from main throughout - Add ConflictResolutionModal component (Radix UI Dialog) with side-by-side local vs server state diff, Discard and Edit & Resubmit strategies - Extend SyncManager with discardPendingUpdate() and resubmitWithResolution() methods for conflict resolution actions - Extend OfflineStorageService: add 'conflict' status to PendingUpdate union, add conflictDetails/stage/pendingId fields, add updatePendingUpdateData() method - Add 21 new sync.* i18n keys (conflict UI strings) to en.json, hi.json, and add missing offline + sync sections to mr.json Closes Nitya-003#619
39e2345 to
a75a536
Compare
- Add a fallback dummy HMAC secret in auditLogger.js to prevent crashes during tests due to missing AUDIT_EVENT_HMAC_SECRET env variable. - Update react-i18next useTranslation t function type signature in global.d.ts to allow additional option arguments, resolving numerous compilation errors across frontend pages.
- In VerificationBadge.test.tsx, update assertions to expect translation keys ('verification.verified' and 'verification.unverified') rather than hardcoded English text.
- In profile/page.test.tsx, update role-based button selectors (profile.editProfile, profile.saveChanges) and toast error validation checks to assert their respective translation keys to align with the i18n implementation.
Contributor
Author
|
Hi @Nitya-003 , you can merge and close |
Nitya-003
approved these changes
Jul 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📌 Overview
This PR implements a Cryptographic Conflict Resolution Engine to safely sequence and merge offline updates in CropChain, addressing potential race conditions and blockchain transaction ordering issues when multiple offline users edit the same batch.
Key Changes:
Logical Versions & Vector Clocks: Added version and vectorClock schemas to the MongoDB batch model to track concurrent updates logic.
Conflict Detection Middleware: Implemented a backend middleware that evaluates incoming sync payloads against the current MongoDB and Blockchain state (expectedVersion logical clocks, vector clock concurrency check, sequential stage transition checks, and on-chain latest update validation).
Idempotency Handling: Gracefully permits identical duplicate offline sync requests while rejecting out-of-sync ones with a 409 Conflict.
WebSocket Push Notifications: Pushes real-time sync conflict alerts to the client on failure.
Radix Manual Resolution UI: Created a beautiful ConflictResolutionModal component that allows users to review current DB/Blockchain state side-by-side with their local state, providing interactive Discard or Edit & Resubmit strategies.
Robust ID Mapping: Integrated remapping of temporary TEMP-xxxx batch IDs to official database IDs for pending updates once batch creation is successfully synced.
🛠️ Type of Change
⛓️ Smart Contract (Solidity changes, Gas optimization)
💻 Frontend (UI/UX, React components, Tailwind)
⚙️ Backend (API routes, MongoDB schemas, Middleware)
📄 Documentation (README, Roadmap updates)
🧪 Testing (Hardhat tests, Jest/Vitest)
🔗 Related Issue
Closes #600
🧪 Testing & Verification
Smart Contracts: NA (Verified via mock smart contract queries, no state changes made to CropChain.sol directly)
Frontend: Yes (Radix UI components verified on desktop and mobile responsive viewport styles)
Integration: Yes (Jest backend test suite verifying logical clocks, vector clock concurrency, stage transition limits, and blockchain state discrepancies)
✅ PR Checklist
My code follows the project's style guidelines.
I have commented my code, particularly in complex areas (e.g., conflict checking rules, vector clock merging).
I have updated the documentation accordingly.
My changes generate no new warnings.
💬 Additional Notes
The backend unit tests are fully configured under backend/tests/conflictDetector.test.js and all 6 tests run successfully without any open handle leakage or database timeouts.