Skip to content

feat: Add Review Queue Locking and Conflict Resolution - #901

Open
deep-bhikadiya wants to merge 6 commits into
Pulsefy:mainfrom
deep-bhikadiya:feature/review-queue-locking
Open

feat: Add Review Queue Locking and Conflict Resolution #901
deep-bhikadiya wants to merge 6 commits into
Pulsefy:mainfrom
deep-bhikadiya:feature/review-queue-locking

Conversation

@deep-bhikadiya

@deep-bhikadiya deep-bhikadiya commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Closes #703


Summary

Implements short-lived locks for verification review to prevent two reviewers from acting on the same verification case simultaneously.

Changes

New Files

  • review-lock.service.ts - Core locking logic (acquire, release, refresh, verify, recover)
  • review-lock.scheduler.ts - Cron job for stale-lock recovery
  • review-lock.dto.ts - DTOs and response types with Swagger docs

Database

Added ReviewLock model to schema with fields:

  • entityType, entityId, lockedBy, lockedAt, expiresAt, status, version

API Endpoints

New:

  • POST /verification-inbox/:id/lock - Acquire lock
  • POST /verification-inbox/lock/release - Release lock
  • POST /verification-inbox/lock/refresh - Refresh lock
  • GET /verification-inbox/:id/lock - Get lock status
  • GET /verification-inbox/locks/my - Get reviewer's active locks
  • GET /verification-inbox/locks/stats - Lock statistics

Modified:

  • POST /verification-inbox/:id/approve - Requires lock ownership
  • POST /verification-inbox/:id/reject - Requires lock ownership
  • POST /verification-inbox/:id/request-resubmission - Requires lock ownership

Acceptance Criteria Met

  1. Review actions fail cleanly when another reviewer holds the lock - Returns structured conflict response with code, message, conflict details
  2. Locks expire safely if a reviewer abandons the case - Default 5 min duration, auto-recovery every 2 min
  3. API responses expose enough detail for frontend conflict UX - LockConflictResponse includes remainingSeconds, suggestedAction ('refresh_page'/'try_again_later'/'force_refresh')

Testing

Run npx prisma db push to apply schema changes

…n\nImplements short-lived locks for verification review to prevent concurrent\nreview actions. Meets acceptance criteria:\n\n- Review actions (approve/reject/request-resubmission) now require lock ownership\n- Locks expire after configurable duration (default 5 minutes)\n- Stale-lock recovery via scheduled job (every 2 minutes)\n- API responses include conflict details for frontend UX\n\nChanges:\n- Add ReviewLock model to Prisma schema\n- Add ReviewLockService with lock acquire/release/refresh/verify\n- Add ReviewLockScheduler for automatic stale-lock recovery\n- Add lock endpoints: POST /:id/lock, POST /lock/release, POST /lock/refresh\n- Add lock status to inbox listing and verification details\n- Integrate lock verification into review action endpoints\n- Add LockConflictResponse with suggestedAction for frontend guidance\n\nCloses Pulsefy#703
@drips-wave

drips-wave Bot commented Jul 29, 2026

Copy link
Copy Markdown

@deep-bhikadiya 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

@deep-bhikadiya deep-bhikadiya changed the title feat: Add Review Queue Locking and Conflict Resolution (#703) feat: Add Review Queue Locking and Conflict Resolution Jul 29, 2026
@Cedarich

Copy link
Copy Markdown
Contributor

Kindly fix failed CI

bhikadiya deep added 2 commits July 30, 2026 10:56
Regenerate the workspace lockfile from the current manifests so frozen installs include the Jest 29 pins and socket.io-client. Remove unused review-lock symbols and format the affected feature files so backend CI can proceed past installation cleanly.

Constraint: Keep the fix scoped to PR Pulsefy#901 and leave local OMX ignore state uncommitted.

Confidence: high

Scope-risk: narrow

Reversibility: clean

Tested: pnpm 10.34.5 frozen install; targeted ESLint; backend build; 678 backend tests plus 4 health tests with local bind permission

Not-tested: GitHub Actions rerun pending push
Merge Pulsefy/Soter main into the feature branch and regenerate pnpm-lock.yaml from the combined manifests to resolve the only content conflict without force-pushing history.

Constraint: Upstream main advanced 29 commits and conflicted only in pnpm-lock.yaml.

Rejected: Keep the branch on its stale merge base | GitHub marked PR Pulsefy#901 unmergeable after the lockfile fix.

Confidence: high

Scope-risk: moderate

Reversibility: clean

Directive: Regenerate pnpm-lock.yaml after future package manifest conflict resolutions.

Tested: pnpm 10.34.5 frozen install; targeted review-lock ESLint; backend build

Not-tested: Full cross-service suite after upstream merge; GitHub Actions pending push
deep-bhikadiya pushed a commit to deep-bhikadiya/Soter that referenced this pull request Jul 30, 2026
Merge Pulsefy/Soter main into the contract-registry branch so CI receives the corrected workspace lockfile and Jest overrides. Remove inherited review-lock lint errors and make the synchronous registry fallback helper accurately non-async.

Constraint: PR Pulsefy#902 was 29 upstream commits behind and inherited the same stale root lockfile importer as PR Pulsefy#901.

Rejected: Regenerate the stale branch lockfile without syncing main | would duplicate upstream dependency policy and leave the branch outdated.

Confidence: high

Scope-risk: moderate

Reversibility: clean

Directive: Keep contract registry fallback paths synchronous unless they acquire real asynchronous work.

Tested: pnpm 10.34.5 frozen install; targeted ESLint; backend build; 5 documented Jest suites with 50 passing tests

Not-tested: Full cross-service suite; GitHub Actions pending push
@Cedarich

Copy link
Copy Markdown
Contributor

@deep-bhikadiya

…he url property in schema.prisma datasource block is no longer supported\nin Prisma 7. Move connection URLs to prisma.config.ts.\n\nSee https://pris.ly/d/config-datasource
@Cedarich

Copy link
Copy Markdown
Contributor

@deep-bhikadiya

Merge the latest upstream main while repairing its incomplete workspace lock graph. Keep the repository-owned workflows unchanged, remove the unused root Prisma 7 conflict so Backend CI resolves Prisma 6, provision the SQLite CI database through backend configuration, and clear the lint blockers exposed after installation.

Constraint: GitHub Actions installs with pnpm 9 and fork-authored workflow changes require maintainer approval.
Rejected: Disable frozen lockfile enforcement | would hide dependency drift instead of repairing it.
Rejected: Modify the workflow | prevents automatic fork checks from running.
Confidence: high
Scope-risk: narrow
Directive: Prisma CLI dependencies belong to app/backend; do not reintroduce a conflicting root Prisma major.
Tested: pnpm 9 frozen install; npx Prisma 6 migration deploy under CI env; ESLint fix dry-run; backend build; 682 backend tests; Node and Python contract suites.
Not-tested: npm package-lock regeneration, which hangs under npm 11 and is not consumed by these checks.
@deep-bhikadiya
deep-bhikadiya force-pushed the feature/review-queue-locking branch from b21d531 to 376f7fa Compare July 31, 2026 04:43
@Cedarich

Copy link
Copy Markdown
Contributor

Kindly resolve conflicts

@Cedarich

Copy link
Copy Markdown
Contributor

Please resolve conflicts

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.

Add Review Queue Locking and Conflict Resolution

2 participants