---
id: WF-COM-CAT-021
title: Reorder Audience Ranks
trigger: >-
  Staff save a new ordering of shared pricing audiences. The console assigns temporary ranks before writing
  the final order, using separate replacements for each record.
product_area: commerce
module: catalog
revision: 1
status: draft
design_intent: proposed
implementation_evidence: observed
source_sha:
  services-commerce: c8b66a98e2490617aec38ba5c8165dd9bd0a8f9b
  react-console: baf6dae382d6f41dce976c7f848667ccc37e076f
implements:
  - CAP-COM-CAT-010
crosses:
  - SVC-COM-CAT-pricing
inference: []
idempotency: No key covers the whole rank change. A later attempt reloads current rows and computes a fresh plan.
concurrency: >-
  Each audience write compares its own version. Unique ranks prevent collisions, but another editor can
  interrupt the sequence after some records have committed.
hops:
  - 'n': 1
    actor_or_service: Console audience adapter
    action: >-
      Load audiences and require the submitted shared set to match, keeping Standard, Member and protected
      ranks fixed.
    anchor: 'react-console:lib/commerce/audiences/live.ts:createLivePricingAudiencesAdapter'
    seam: sync
    on_failure: Reject a changed set or an ordering that cannot fit around protected ranks.
    left_inconsistent: No rank write has run.
    observer: The form displays returned errors and staff can reload saved records.
    provenance: observed
    source: 'react-console:lib/commerce/audiences/live.ts:createLivePricingAudiencesAdapter'
  - 'n': 2
    actor_or_service: Console audience adapter
    action: >-
      Move each changing audience to a distinct rank above all current and target ranks, retaining the
      returned version.
    anchor: 'react-console:lib/commerce/audiences/live.ts:createLivePricingAudiencesAdapter'
    seam: sync
    on_failure: Stop on the first failed replacement without undoing earlier replacements.
    left_inconsistent: Some audiences may remain parked above their intended positions.
    observer: The form displays returned errors and staff can reload saved records.
    provenance: observed
    source: 'react-console:lib/commerce/audiences/live.ts:createLivePricingAudiencesAdapter'
  - 'n': 3
    actor_or_service: Console audience adapter
    action: Replace each parked audience with its final target rank using the latest returned version.
    anchor: 'react-console:lib/commerce/audiences/live.ts:createLivePricingAudiencesAdapter'
    seam: sync
    on_failure: Stop on the first failed final assignment and return the conflict or service error.
    left_inconsistent: The saved ranking can mix final positions and temporary parking ranks.
    observer: The form displays returned errors and staff can reload saved records.
    provenance: observed
    source: 'react-console:lib/commerce/audiences/live.ts:createLivePricingAudiencesAdapter'
evidence:
  - 'react-console:lib/commerce/audiences/live.ts:createLivePricingAudiencesAdapter'
controls: [TC-AZ-001, TC-AZ-002, TC-AZ-003, TC-AZ-004, TC-AZ-005, TC-AZ-006, TC-TEN-001, TC-TEN-002, TC-TEN-003, TC-CRY-001, TC-CRY-004, TC-DAT-001, TC-DAT-002, TC-DAT-003, TC-LOG-004, TC-LOG-005, TC-PI-001, TC-PI-003, TC-PI-005, TC-PRV-001, TC-PRV-002]
---

# Reorder Audience Ranks

## What It Does

Staff save a new ordering of shared pricing audiences. The console assigns temporary ranks before writing the final order, using separate replacements for each record.

## The Flow

```mermaid
sequenceDiagram
  participant Staff
  participant Console
  participant Pricing
  Staff->>Console: Save audience order
  Console->>Pricing: Read current audiences
  loop Moving audiences
    Console->>Pricing: Replace with unused temporary rank
  end
  loop Parked audiences
    Console->>Pricing: Replace with final rank
  end
```

## When Something Fails

Reject a changed set or an ordering that cannot fit around protected ranks. No rank write has run. Stop on the first failed replacement without undoing earlier replacements. Some audiences may remain parked above their intended positions. Stop on the first failed final assignment and return the conflict or service error. The saved ranking can mix final positions and temporary parking ranks.

## Open Design Questions

Product should decide whether ordering needs an atomic service operation or an explicit recovery experience. The current dialog retains errors and provides reloading rather than compensation.
