Skip to content

Add manual patron request termination#636

Open
jakub-id wants to merge 1 commit into
mainfrom
terminal-close
Open

Add manual patron request termination#636
jakub-id wants to merge 1 commit into
mainfrom
terminal-close

Conversation

@jakub-id

@jakub-id jakub-id commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

https://index-data.atlassian.net/browse/CROSSLINK-275

Summary

  • add special POST /patron_requests/{id}/terminate endpoint
  • add manualClose terminal state metadata and MANUALLY_CLOSED returnables states
  • process termination through invoke-action without exposing it as a normal action

Tests

  • go test ./patron_request/api ./patron_request/service
  • go test ./app
  • pre-push lint and Docker build hooks passed

Copilot AI review requested due to automatic review settings June 12, 2026 13:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a dedicated “manual termination” flow for patron requests by introducing a new POST /patron_requests/{id}/terminate endpoint that drives a special internal terminate action through the existing invoke-action task path, without exposing terminate as a normal state-model action.

Changes:

  • Added a terminal MANUALLY_CLOSED state (per side) and a manualClose marker to designate the termination target state.
  • Implemented a special-case terminate action handler in the patron request action service that directly transitions a non-terminal request to the configured manual-close terminal state.
  • Added a new API endpoint and tests ensuring terminate is rejected via the generic /action endpoint but succeeds via /terminate.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
broker/patron_request/service/statemodels/returnables.json Adds MANUALLY_CLOSED terminal states for requester/supplier and marks them as manualClose targets.
broker/patron_request/service/statemodel.go Validates manualClose is only set on terminal states and is unique per side.
broker/patron_request/service/statemodel_test.go Adds unit tests for the new manualClose validation rules.
broker/patron_request/service/statemodel_capabilities.go Registers MANUALLY_CLOSED as a built-in state and defines the internal terminate action constant.
broker/patron_request/service/action.go Routes internal terminate action to a dedicated handler that updates state/terminal metadata without LMS involvement.
broker/patron_request/service/action_test.go Adds tests for successful termination and rejection when already terminal.
broker/patron_request/service/action_mapping.go Extracts and exposes the per-side manual-close target state from the state model; adds IsTerminalState.
broker/patron_request/service/action_mapping_test.go Tests manual-close state lookup and ensures terminate is not a normal available action.
broker/patron_request/api/api-handler.go Adds POST /patron_requests/{id}/terminate, refactors invoke-action request construction, and reuses a shared invoke+respond helper.
broker/patron_request/api/api-handler_test.go Tests that /action rejects terminate, and /terminate creates the correct invoke-action task payload and rejects terminal PRs.
broker/oapi/open-api.yaml Extends ModelState with manualClose and adds the /patron_requests/{id}/terminate route.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants