Skip to content

CROSSLINK-231 last action info#466

Open
adamdickmeiss wants to merge 25 commits intomainfrom
CROSSLINK-231-last-action-stuff
Open

CROSSLINK-231 last action info#466
adamdickmeiss wants to merge 25 commits intomainfrom
CROSSLINK-231-last-action-stuff

Conversation

@adamdickmeiss
Copy link
Contributor

@adamdickmeiss adamdickmeiss commented Mar 17, 2026

Extend the patron_request structure with last_action, last_action_outcome,
last_action_result. Not populated yet with any values.
@adamdickmeiss adamdickmeiss requested a review from jakub-id as a code owner March 17, 2026 15:05
Copilot AI review requested due to automatic review settings March 17, 2026 15:05
@adamdickmeiss adamdickmeiss marked this pull request as draft March 17, 2026 15:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds database support for capturing “last action” metadata on patron requests, with corresponding query and API schema updates to surface these fields through the broker’s Patron Request model.

Changes:

  • Adds last_action, last_action_outcome, and last_action_result columns to patron_request (schema + migration).
  • Updates patron request create/update SQL and the CQL-backed list scanning to include the new columns.
  • Extends the OpenAPI PatronRequest schema with the new fields.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
broker/sqlc/pr_schema.sql Extends patron_request table definition with last-action columns.
broker/sqlc/pr_query.sql Persists last-action columns in Create/Update queries.
broker/patron_request/db/prcql.go Updates CQL list scan order to include new columns.
broker/oapi/open-api.yaml Documents new PatronRequest fields in the API schema.
broker/migrations/019_last_action.up.sql Migration to add new patron_request columns.
broker/migrations/019_last_action.down.sql Rollback migration to drop the new columns.

You can also share your feedback on Copilot code review. Take the survey.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds “last action” metadata to Patron Requests so API consumers can see the most recent executed action and its outcome/status, supporting CROSSLINK-231 (first part).

Changes:

  • Extend patron_request schema + migrations with last_action, last_action_outcome, last_action_result.
  • Populate these fields when actions are finalized, and expose them via the Patron Request API + OpenAPI schema.
  • Update CQL list scanning and add/extend API tests to assert the new fields.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
broker/test/patron_request/api/api-handler_test.go Adds assertions for last-action fields and adjusts expectations around a failing blocking action.
broker/sqlc/pr_schema.sql Adds new patron_request columns to sqlc schema.
broker/sqlc/pr_query.sql Updates Create/Update queries to include last-action columns.
broker/patron_request/service/action.go Sets last-action fields during action finalization.
broker/patron_request/db/prcql.go Extends manual rows.Scan to include the new columns.
broker/patron_request/api/api-handler.go Maps new DB fields into API PatronRequest response.
broker/oapi/open-api.yaml Documents last-action fields on PatronRequest schema.
broker/migrations/019_last_action.up.sql Migration to add last-action columns.
broker/migrations/019_last_action.down.sql Rollback migration to drop last-action columns.

You can also share your feedback on Copilot code review. Take the survey.

@adamdickmeiss adamdickmeiss marked this pull request as ready for review March 18, 2026 16:22
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds “last action” tracking to Patron Requests so the system can persist and expose the most recent executed action along with its outcome and event status.

Changes:

  • Add last_action, last_action_outcome, last_action_result columns to patron_request (schema + migration) and wire them into sqlc create/update/list queries.
  • Persist last-action metadata on every action execution and expose it via the PatronRequest API + OpenAPI schema.
  • Extend CRUD API tests to assert last-action fields after create/action execution.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
broker/test/patron_request/api/api-handler_test.go Adds assertions for last action/outcome/result after create and after executing actions.
broker/sqlc/pr_schema.sql Extends patron_request table definition with last-action columns.
broker/sqlc/pr_query.sql Updates Create/Update queries to include last-action fields.
broker/patron_request/service/action_mapping.go Refactors action-availability helpers; adds logic intended to filter auto-actions based on failure.
broker/patron_request/service/action.go Persists last-action fields during action finalization (always updates PR).
broker/patron_request/db/prcql.go Updates manual rows.Scan mapping to include last-action columns.
broker/patron_request/api/api-handler.go Maps last-action fields into API responses; documents that they’re unset at creation time.
broker/oapi/open-api.yaml Adds lastAction/lastActionOutcome/lastActionResult to the PatronRequest schema.
broker/migrations/019_last_action.up.sql Migration adding last-action columns.
broker/migrations/019_last_action.down.sql Rollback migration dropping last-action columns.

You can also share your feedback on Copilot code review. Take the survey.

adamdickmeiss and others added 3 commits March 18, 2026 17:34
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@adamdickmeiss adamdickmeiss marked this pull request as draft March 18, 2026 17:15
@adamdickmeiss adamdickmeiss requested a review from Copilot March 19, 2026 08:51
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds persisted “last action” metadata to patron requests so API consumers can see the most recent workflow action and its outcome/status, aligning runtime behavior with CROSSLINK-231.

Changes:

  • Adds last_action, last_action_outcome, last_action_result columns (schema + migration) and wires them through sqlc queries and CQL scanning.
  • Persists last action info on every executed action and exposes the fields in the PatronRequest API + OpenAPI schema.
  • Extends API integration tests to assert last-action fields after key actions.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
broker/test/patron_request/api/api-handler_test.go Adds assertions verifying last action/outcome/result in API responses.
broker/sqlc/pr_schema.sql Extends patron_request table schema with last-action columns.
broker/sqlc/pr_query.sql Updates insert/update queries to include last-action columns.
broker/patron_request/service/action_mapping.go Adjusts action listing/availability logic with awareness of last action result.
broker/patron_request/service/action.go Updates action finalization to persist last-action metadata on patron requests.
broker/patron_request/db/prcql.go Updates manual rows.Scan order to match new patron_request column order.
broker/patron_request/api/api-handler.go Maps last-action fields into API PatronRequest responses.
broker/oapi/open-api.yaml Documents lastAction/lastActionOutcome/lastActionResult in OpenAPI.
broker/migrations/019_last_action.up.sql Migration adding last-action columns.
broker/migrations/019_last_action.down.sql Migration removing last-action columns.

You can also share your feedback on Copilot code review. Take the survey.

@adamdickmeiss adamdickmeiss requested a review from Copilot March 19, 2026 09:25
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds “last action” metadata to patron requests so API consumers can see the most recent action name, outcome, and event status for a request (CROSSLINK-231).

Changes:

  • Add last_action, last_action_outcome, last_action_result columns to patron_request (schema + migration) and include them in sqlc queries/CQL scanning.
  • Persist last-action fields during action execution and expose them via the Patron Request API + OpenAPI schema.
  • Extend API integration tests to assert last-action fields are returned/updated.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
broker/test/patron_request/api/api-handler_test.go Asserts last-action fields in CRUD flow and after executing actions.
broker/sqlc/pr_schema.sql Adds last-action columns to the patron_request table definition used by sqlc.
broker/sqlc/pr_query.sql Updates Create/Update queries to include last-action columns.
broker/patron_request/service/action_mapping.go Changes action availability logic to optionally include auto actions after failures, using last-action fields.
broker/patron_request/service/action.go Persists last-action fields on every action finalization via UpdatePatronRequest.
broker/patron_request/db/prcql.go Updates manual rows.Scan arg list to match new patron_request column order.
broker/patron_request/api/api-handler.go Re-reads PR after auto-actions so response includes updated last-action fields; maps new fields to API model.
broker/oapi/open-api.yaml Documents lastAction/lastActionOutcome/lastActionResult on PatronRequest.
broker/migrations/019_last_action.up.sql Adds last-action columns to patron_request at runtime.
broker/migrations/019_last_action.down.sql Removes last-action columns on rollback.

You can also share your feedback on Copilot code review. Take the survey.

@adamdickmeiss adamdickmeiss requested a review from Copilot March 19, 2026 10:25
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds end-to-end support for tracking the most recent action performed on a patron request (action name, outcome, and status), persisting it in Postgres and exposing it via the PatronRequest API.

Changes:

  • Add last_action, last_action_outcome, last_action_result columns + migration and sqlc query updates.
  • Persist last-action fields on every action finalization and expose them in API responses/OpenAPI.
  • Update action availability logic to optionally include auto-actions after a failed last action; extend tests accordingly.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
broker/test/patron_request/api/api-handler_test.go Extends integration CRUD test assertions to validate last-action fields across POST and action execution.
broker/sqlc/pr_schema.sql Adds last-action columns to patron_request table schema definition.
broker/sqlc/pr_query.sql Updates Create/Update queries to include last-action columns.
broker/patron_request/service/action_mapping_test.go Adds coverage for GetActionsForPatronRequest behavior with/without state model and for failed last action.
broker/patron_request/service/action_mapping.go Computes available actions based on state model + last action failure status (incl. auto-action handling).
broker/patron_request/service/action.go Ensures last-action fields are updated and persisted on every action execution finalization.
broker/patron_request/db/prcql.go Updates manual rows.Scan to match new column order (including last-action fields).
broker/patron_request/api/api-handler.go Re-fetches PR after auto-actions and maps last-action fields into API model.
broker/oapi/open-api.yaml Documents lastAction/lastActionOutcome/lastActionResult fields on PatronRequest.
broker/migrations/019_last_action.up.sql Adds last-action columns via migration.
broker/migrations/019_last_action.down.sql Drops last-action columns via rollback migration.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines 231 to +242
respBytes = httpRequest(t, "POST", thisPrPath+"/action"+queryParams, actionBytes, 200)
// used to succeed, but the illmock currently does not include items as part of the Loaned message, which causes the action to fail.
// We should either update the mock to include items or change the test to not use blocking action.
assert.Equal(t, "{\"actionResult\":\"ERROR\"}\n", string(respBytes))

respBytes = httpRequest(t, "GET", thisPrPath+queryParams, []byte{}, 200)
err = json.Unmarshal(respBytes, &foundPr)
assert.NoError(t, err, "failed to unmarshal patron request")
assert.Equal(t, *newPr.Id, foundPr.Id)
assert.Equal(t, "receive", *foundPr.LastAction)
assert.Equal(t, "failure", *foundPr.LastActionOutcome)
assert.Equal(t, "ERROR", *foundPr.LastActionResult)
@adamdickmeiss adamdickmeiss marked this pull request as ready for review March 19, 2026 10:50
return
}
}
pr, err = a.prRepo.GetPatronRequestById(ctx, pr.ID)
Copy link
Contributor

Choose a reason for hiding this comment

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

@adamdickmeiss it would be more clear if RunAutoActionsOnStateEntry returned an updated version of pr

return r.SMService
}

type ActionEntry struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

@adamdickmeiss could we rename this to PatronRequestAction and the string to ActionName

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.

4 participants