Skip to content

fix(api): preserve worker claims when pausing purchases - #468

Open
cristim wants to merge 1 commit into
mainfrom
fix/pause-claimed-execution
Open

cristim wants to merge 1 commit into
mainfrom
fix/pause-claimed-execution

Conversation

@cristim

@cristim cristim commented Oct 1, 2026

Copy link
Copy Markdown
Member

Pausing an execution already claimed by a worker changed it from running to paused. Resuming made it pending again, allowing a second worker to enter the purchase while the first was still active. Restrict Pause to pending executions so the atomic status transition preserves the worker's claim. Pending pause/resume remains supported; ineligible states return 409, now documented on the endpoint.

Closes #223

Independent gpt-6-astra review approved exact commit 1c5a14964444ed1015dee47346e875809e616ac8 under the authorized local review alternative, with no actionable findings in both implementation rounds or final committed-source review.

Fresh independent PostgreSQL 16 race-enabled tests exercised the production handler, store and Manager.ProcessMessage with synthetic provider, credential, auth-session and email boundaries. They assert both claim/pause orderings, unchanged claim attribution, one provider purchase and one persisted history row, queued redelivery safety, and legitimate pending pause/resume. The committed regression against the parent handler failed on two provider entries and two history rows; removing pending from the allowed set failed the valid pause control. Four connected scenarios also passed three independent race-enabled repetitions before commit.

The full untagged race suite, backend build and normal installed hooks passed. No live-cloud purchase was performed. CI is a separate publication gate.

Restrict pause to pending executions so pause/resume cannot release a
running worker's claim and let a second worker enter the purchase path.
Cover both race orders, queue redelivery, actor state, and history with
real PostgreSQL and synthetic provider boundaries.

Closes #223
@cristim cristim added severity/medium Moderate harm urgency/this-sprint Within the current sprint triaged Item has been triaged priority/p1 Next up; this sprint impact/few Limited audience effort/xs Trivial / one-liner type/bug Defect labels Oct 1, 2026
@coderabbitai

coderabbitai Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

  • Run on-demand review

This review includes 6 billable files and costs up to $1.50.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 29 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 75 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository: LeanerCloud/cloud-commitments-platform/.coderabbit.yaml

Review profile: CHILL

Plan: Essentials

Run ID: 13f32d05-e987-4e7d-b8d2-64f1a0361fcf

📥 Commits

Reviewing files that changed from the base of the PR and between 6d9a70f and 1c5a149.

📒 Files selected for processing (6)
  • internal/api/handler_purchases.go
  • internal/api/handler_purchases_pause_claim_integration_test.go
  • internal/api/handler_purchases_test.go
  • internal/api/handler_test.go
  • internal/api/openapi.yaml
  • internal/api/router_660_permission_flips_test.go
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

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

Labels

effort/xs Trivial / one-liner impact/few Limited audience priority/p1 Next up; this sprint severity/medium Moderate harm triaged Item has been triaged type/bug Defect urgency/this-sprint Within the current sprint

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(api): pausing a running execution allows a claimed purchase to be re-claimed

1 participant