Conversation
WalkthroughNarrow VLP handling to a single latest verification transaction per applicant, remove automatic VLP triggering after saving SSA response payloads, derive VLP close-case payloads from the subject's last transaction, adjust control flow and tests to match the single-transaction approach. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant Processor as ProcessApplicantResponses
participant Txns as applicant.transactions
participant VLP as process_vlp_verification_response
User->>Processor: update_dhs_verification_response(applications)
loop per applicant
Processor->>Txns: find last :vlp_verification_response
alt transaction found
Processor->>VLP: process(transaction)
alt success
Processor-->>User: update application_hash
else failure
Processor-->>User: early Failure
end
else no transaction
Processor-->>User: skip applicant
end
end
sequenceDiagram
autonumber
participant Client
participant HandleReq as VLP::CloseCase::HandleRequest
participant Applicants as Applicants[]
participant AppReq as VLP::CloseCase::ApplicantRequest
participant Txns as applicant.transactions
Client->>HandleReq: process_close_case_requests(payload, job)
HandleReq->>Applicants: filter by payload.hbx_ids
alt none found
HandleReq-->>Client: Failure (no applicants)
else found
loop each applicant
AppReq->>Txns: get last :vlp_verification_response
alt exists
AppReq-->>HandleReq: Success(payload)
else missing
AppReq-->>HandleReq: Failure (payload generation failed)
end
end
HandleReq-->>Client: Aggregate results
end
sequenceDiagram
autonumber
participant SSA as SSA::ApplicantRequest
participant Store as ResponsePayloadStore
SSA->>Store: save_response_payload(params)
note right of SSA: removed call to trigger VLP after save
SSA-->>Store: Success/Failure
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
app/operations/fdsh/ssa_vlp/rj3/vlp/close_case/applicant_request.rb (1)
54-54: Use explicit ordering for deterministic query resultsReplace the
lastcall with an explicit order to ensure the most recent transaction is always selected:-vlp_transaction = @subject.transactions.where(key: :vlp_verification_response).last +vlp_transaction = @subject.transactions.where(key: :vlp_verification_response).order(created_at: :desc).firstAudit other similar patterns across the codebase with:
rg -n '\.where\([^)]+\)\.last' -g '*.rb' -A2 -B2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
app/operations/fdsh/ssa_vlp/rj3/process_applicant_responses.rb(2 hunks)app/operations/fdsh/ssa_vlp/rj3/ssa/applicant_request.rb(0 hunks)app/operations/fdsh/ssa_vlp/rj3/vlp/close_case/applicant_request.rb(3 hunks)app/operations/fdsh/ssa_vlp/rj3/vlp/close_case/handle_request.rb(1 hunks)spec/operations/fdsh/ssa_vlp/rj3/ssa/applicant_request_spec.rb(0 hunks)spec/operations/fdsh/ssa_vlp/rj3/vlp/close_case/applicant_request_spec.rb(2 hunks)spec/operations/fdsh/ssa_vlp/rj3/vlp/close_case/handle_request_spec.rb(0 hunks)
💤 Files with no reviewable changes (3)
- spec/operations/fdsh/ssa_vlp/rj3/ssa/applicant_request_spec.rb
- app/operations/fdsh/ssa_vlp/rj3/ssa/applicant_request.rb
- spec/operations/fdsh/ssa_vlp/rj3/vlp/close_case/handle_request_spec.rb
🧰 Additional context used
🧬 Code graph analysis (4)
spec/operations/fdsh/ssa_vlp/rj3/vlp/close_case/applicant_request_spec.rb (1)
app/operations/fdsh/ssa_vlp/rj3/vlp/close_case/applicant_request.rb (1)
call(16-30)
app/operations/fdsh/ssa_vlp/rj3/vlp/close_case/handle_request.rb (1)
app/operations/fdsh/ssa_vlp/rj3/vlp/close_case/applicant_request.rb (1)
call(16-30)
app/operations/fdsh/ssa_vlp/rj3/vlp/close_case/applicant_request.rb (1)
app/models/transmittable/transmission.rb (1)
transactions(127-129)
app/operations/fdsh/ssa_vlp/rj3/process_applicant_responses.rb (1)
app/models/transmittable/transmission.rb (1)
transactions(127-129)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: build-and-upload-image
- GitHub Check: rspec
🔇 Additional comments (7)
app/operations/fdsh/ssa_vlp/rj3/vlp/close_case/applicant_request.rb (1)
17-17: LGTM!The removal of
vlp_transactionfrom the parameter list aligns with the new approach of deriving the transaction from the subject's history rather than passing it explicitly.Also applies to: 38-38
app/operations/fdsh/ssa_vlp/rj3/process_applicant_responses.rb (2)
48-56: LGTM!The simplified approach of processing a single VLP verification response per applicant (instead of iterating over multiple transactions) aligns with the PR's objective to revert to the previous behavior.
78-78: Verify query ordering for deterministic results.Similar to the concern in
applicant_request.rb, using.lastwithout explicit ordering could lead to non-deterministic behavior. Consider making the ordering explicit.Consider applying this diff:
-applicant.transactions.where(key: :vlp_verification_response).last +applicant.transactions.where(key: :vlp_verification_response).order(created_at: :desc).firstspec/operations/fdsh/ssa_vlp/rj3/vlp/close_case/applicant_request_spec.rb (2)
61-61: LGTM!The test parameters correctly reflect the updated
ApplicantRequestinterface, which no longer requiresvlp_transactionto be passed explicitly.
116-120: LGTM!The test appropriately validates the new behavior where the VLP transaction is retrieved from the applicant's transaction history. Destroying the transaction and verifying the failure path ensures the implementation handles missing transactions correctly.
app/operations/fdsh/ssa_vlp/rj3/vlp/close_case/handle_request.rb (2)
55-56: LGTM!The guard clause that returns a
Failurewhen no applicants match the payload is good defensive programming and provides clear feedback when the payload doesn't align with the application's applicants.
58-60: LGTM!The simplified call to
ApplicantRequestwith onlyapplicantandjobparameters is consistent with the changes across the codebase, wherevlp_transactionis now derived from the applicant's transaction history rather than passed explicitly.
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
app/operations/fdsh/ssa_vlp/rj3/response_processor_utils.rb(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: build-and-upload-image
- GitHub Check: rspec
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
app/operations/fdsh/ssa_vlp/rj3/response_processor_utils.rb(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-07-15T16:28:40.423Z
Learnt from: vkghub
PR: ideacrew/fdsh_gateway#268
File: app/operations/fdsh/ssa_vlp/rj3/vlp/process_verification_response.rb:119-123
Timestamp: 2025-07-15T16:28:40.423Z
Learning: In `app/operations/fdsh/ssa_vlp/rj3/vlp/process_verification_response.rb`, the application hash structure guarantees that top level keys like `:person_name` and `:demographics` will always be present, so direct hash access in `name_and_dob_match?` method is safe and doesn't require defensive navigation using `dig`.
Applied to files:
app/operations/fdsh/ssa_vlp/rj3/response_processor_utils.rb
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: build-and-upload-image
- GitHub Check: rspec
https://app.clickup.com/t/868fubywe
Reverting commits:
5efd894
e49f98c
Summary by CodeRabbit