---
id: ATS-COM-ORD-013
scope: CAP-COM-ORD-013
product_area: commerce
module: orders
revision: 2
status: proposed
approved_by: null
approved_at: null
source_sha:
  services-commerce: c8b66a98e2490617aec38ba5c8165dd9bd0a8f9b
  macroservice-libraries: 54536a441935c6e09fdb7f96f0bec71c52ba4e03
  react-console: baf6dae382d6f41dce976c7f848667ccc37e076f
scenarios:
  - id: ATS-COM-ORD-013-01
    title: Grant delivery reads the frozen purchase
    level: api
    proves:
      - BR-CAP-COM-ORD-013-01
    preconditions: An e-book purchase contains an entitlement specification.
    steps:
      - do: 'Place, pay and deliver its grant obligation.'
        provenance: test
        source: >-
          services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#placed the e-book with a
          plan of the register’s own kind and the download specification frozen on the line
    expected: The purchase retains the specification and the completed obligation identifies its grant record.
    negative: false
    data_needs: Use the controlled records and transports established by the cited tests.
    bound_to:
      - >-
        services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#placed the e-book with a
        plan of the register’s own kind and the download specification frozen on the line
      - >-
        services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#delivered the obligation to
        the register: completed, with the grant as its record
      - TST-COM-ORD-061
    provenance: test
    source: >-
      services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#placed the e-book with a plan
      of the register’s own kind and the download specification frozen on the line
    category: transition
    expected_provenance: test
    expected_source: >-
      services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#placed the e-book with a plan
      of the register’s own kind and the download specification frozen on the line
  - id: ATS-COM-ORD-013-02
    title: Copies do not multiply a specified grant limit
    level: api
    proves:
      - BR-CAP-COM-ORD-013-02
    preconditions: Three copies each carry the purchase-level two-download declaration.
    steps:
      - do: 'Place and fulfil the purchase, then consume its right.'
        provenance: test
        source: >-
          services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#grants ONE download right
          of two uses for the three copies, not six
    expected: 'One two-use grant exists, without a six-use multiplication.'
    negative: false
    data_needs: Use the controlled records and transports established by the cited tests.
    bound_to:
      - >-
        services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#grants ONE download right of
        two uses for the three copies, not six
      - >-
        services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#gives two downloads and
        refuses the third 409 insufficient_entitlement
      - TST-COM-ORD-061
    provenance: test
    source: >-
      services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#grants ONE download right of
      two uses for the three copies, not six
    category: rule
    expected_provenance: test
    expected_source: >-
      services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#grants ONE download right of
      two uses for the three copies, not six
  - id: ATS-COM-ORD-013-03
    title: Holder resolution honors recipient or buyer selection
    level: unit
    proves:
      - BR-CAP-COM-ORD-013-03
    preconditions: 'Inputs name a recipient, omit one or explicitly choose the buyer.'
    steps:
      - do: Resolve the holder for each specification.
        provenance: test
        source: >-
          services-commerce:modules/entitlements/tests/unit/register/grant-specification.spec.js#gives the
          grant to the line’s recipient, to the buyer when the line names none, and to the buyer when the spec
          says so
    expected: 'The results select the recipient, buyer fallback or explicit buyer respectively.'
    negative: false
    data_needs: Use the controlled records and transports established by the cited tests.
    bound_to:
      - >-
        services-commerce:modules/entitlements/tests/unit/register/grant-specification.spec.js#gives the grant
        to the line’s recipient, to the buyer when the line names none, and to the buyer when the spec says so
      - TST-COM-ORD-071
    provenance: test
    source: >-
      services-commerce:modules/entitlements/tests/unit/register/grant-specification.spec.js#gives the grant
      to the line’s recipient, to the buyer when the line names none, and to the buyer when the spec says so
    category: edge
    expected_provenance: test
    expected_source: >-
      services-commerce:modules/entitlements/tests/unit/register/grant-specification.spec.js#gives the grant
      to the line’s recipient, to the buyer when the line names none, and to the buyer when the spec says so
  - id: ATS-COM-ORD-013-04
    title: A missing grant specification fails permanently
    level: api
    proves:
      - BR-CAP-COM-ORD-013-04
    preconditions: A grant obligation references purchase details without a readable specification.
    steps:
      - do: Process the obligation.
        provenance: test
        source: >-
          services-commerce:modules/entitlements/tests/integration/services/register/grant-handler.integration.spec.js#fails
          the obligation of a purchase that names no specification, not retryable, with obligation_failed
          raised
    expected: 'The obligation fails non-retryably, creates no right and raises obligation_failed.'
    negative: true
    data_needs: Use the controlled records and transports established by the cited tests.
    bound_to:
      - >-
        services-commerce:modules/entitlements/tests/integration/services/register/grant-handler.integration.spec.js#fails
        the obligation of a purchase that names no specification, not retryable, with obligation_failed raised
      - TST-COM-ORD-069
    provenance: test
    source: >-
      services-commerce:modules/entitlements/tests/integration/services/register/grant-handler.integration.spec.js#fails
      the obligation of a purchase that names no specification, not retryable, with obligation_failed raised
    category: failure
    expected_provenance: test
    expected_source: >-
      services-commerce:modules/entitlements/tests/integration/services/register/grant-handler.integration.spec.js#fails
      the obligation of a purchase that names no specification, not retryable, with obligation_failed raised
  - id: ATS-COM-ORD-013-05
    title: Consumption replay does not spend an extra use
    level: api
    proves:
      - BR-CAP-COM-ORD-013-05
    preconditions: A download right has two available uses.
    steps:
      - do: 'Download, replay the first request, make the second request and attempt a third.'
        provenance: test
        source: >-
          services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#gives the member a link
          and consumes one use per Idempotency-Key (the retry free), then refuses the third 409
          insufficient_entitlement
    expected: Only two uses are consumed and the final independent request receives insufficient_entitlement.
    negative: false
    data_needs: Use the controlled records and transports established by the cited tests.
    bound_to:
      - >-
        services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#gives the member a link and
        consumes one use per Idempotency-Key (the retry free), then refuses the third 409
        insufficient_entitlement
      - TST-COM-ORD-061
    provenance: test
    source: >-
      services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#gives the member a link and
      consumes one use per Idempotency-Key (the retry free), then refuses the third 409
      insufficient_entitlement
    category: invariant
    expected_provenance: test
    expected_source: >-
      services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#gives the member a link and
      consumes one use per Idempotency-Key (the retry free), then refuses the third 409
      insufficient_entitlement
  - id: ATS-COM-ORD-013-06
    title: Restoration returns one consumed use with audit evidence
    level: api
    proves:
      - BR-CAP-COM-ORD-013-06
    preconditions: Both uses on a grant are consumed.
    steps:
      - do: 'Restore the first use, replay that request, try another key and consume again.'
        provenance: test
        source: >-
          services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#restores use 1 (an
          intervention: the log row, the history, the audit event), replays under the same key, refuses the
          same use under another
    expected: >-
      The restoration has intervention, history and audit records; replay is free and a duplicate restoration
      is refused.
    negative: false
    data_needs: Use the controlled records and transports established by the cited tests.
    bound_to:
      - >-
        services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#restores use 1 (an
        intervention: the log row, the history, the audit event), replays under the same key, refuses the same
        use under another
      - >-
        services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#lets the member download
        once more, and no more
      - TST-COM-ORD-061
    provenance: test
    source: >-
      services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#restores use 1 (an
      intervention: the log row, the history, the audit event), replays under the same key, refuses the same
      use under another
    category: transition
    expected_provenance: test
    expected_source: >-
      services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#restores use 1 (an
      intervention: the log row, the history, the audit event), replays under the same key, refuses the same
      use under another
  - id: ATS-COM-ORD-013-07
    title: Manual interventions retain source and reason
    level: api
    proves:
      - BR-CAP-COM-ORD-013-07
    preconditions: Staff can grant rights to a contact without a sale and can revoke a purchased right.
    steps:
      - do: 'Grant, revoke, retry revocation and submit an invalid window.'
        provenance: test
        source: >-
          services-commerce:modules/entitlements/tests/integration/services/entitlements/entitlement-interventions.integration.spec.js#writes
          a manual grant with no order, line or obligation, the window stated, the reason in its notes
    expected: >-
      The manual source and reason remain, used quantities survive revocation, repetition is refused and the
      invalid window returns 400.
    negative: false
    data_needs: Use the controlled records and transports established by the cited tests.
    bound_to:
      - >-
        services-commerce:modules/entitlements/tests/integration/services/entitlements/entitlement-interventions.integration.spec.js#writes
        a manual grant with no order, line or obligation, the window stated, the reason in its notes
      - >-
        services-commerce:modules/entitlements/tests/integration/services/entitlements/entitlement-interventions.integration.spec.js#moves
        it to revoked with the staff reason, the used quantity standing
      - >-
        services-commerce:modules/entitlements/tests/integration/services/entitlements/entitlement-interventions.integration.spec.js#refuses
        a second revoke 409 entitlement_not_revocable, logging nothing more
      - >-
        services-commerce:modules/entitlements/tests/integration/services/entitlements/entitlement-interventions.integration.spec.js#revokes
        it whatever its source, with the intervention and the revocation on the order’s history
      - >-
        services-commerce:modules/entitlements/tests/integration/services/entitlements/entitlement-interventions.integration.spec.js#refuses
        a window that ends before it starts, writing neither the grant nor the intervention
      - TST-COM-ORD-064
    provenance: test
    source: >-
      services-commerce:modules/entitlements/tests/integration/services/entitlements/entitlement-interventions.integration.spec.js#writes
      a manual grant with no order, line or obligation, the window stated, the reason in its notes
    category: permission
    expected_provenance: test
    expected_source: >-
      services-commerce:modules/entitlements/tests/integration/services/entitlements/entitlement-interventions.integration.spec.js#writes
      a manual grant with no order, line or obligation, the window stated, the reason in its notes
  - id: ATS-COM-ORD-013-08
    title: Cancellation revocation prevents further download
    level: api
    proves:
      - BR-CAP-COM-ORD-013-08
    preconditions: A purchased e-book right remains linked to its line.
    steps:
      - do: Invoke cancellation revocation and attempt download.
        provenance: test
        source: >-
          services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#revokes the line’s grant
          with the reason, refuses the download 409 entitlement_not_active, and writes the history
    expected: 'The grant is revoked with its reason, use history stays and the download returns entitlement_not_active.'
    negative: true
    data_needs: Use the controlled records and transports established by the cited tests.
    bound_to:
      - >-
        services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#revokes the line’s grant
        with the reason, refuses the download 409 entitlement_not_active, and writes the history
      - TST-COM-ORD-061
    provenance: test
    source: >-
      services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#revokes the line’s grant with
      the reason, refuses the download 409 entitlement_not_active, and writes the history
    category: interaction
    expected_provenance: test
    expected_source: >-
      services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#revokes the line’s grant with
      the reason, refuses the download 409 entitlement_not_active, and writes the history
  - id: ATS-COM-ORD-013-09
    title: Expiry processing affects only elapsed windows
    level: api
    proves:
      - BR-CAP-COM-ORD-013-09
    preconditions: 'Grants include expired, live, unbounded and revoked fixtures.'
    steps:
      - do: Run expiry processing and repeat it.
        provenance: test
        source: >-
          services-commerce:modules/entitlements/tests/integration/services/register/entitlement-sweeper.integration.spec.js#expires
          the lapsed grants of both tenants, oldest expiry first, and counts what it did
    expected: 'Only active elapsed-window grants change, with no repeated expiry write.'
    negative: false
    data_needs: Use the controlled records and transports established by the cited tests.
    bound_to:
      - >-
        services-commerce:modules/entitlements/tests/integration/services/register/entitlement-sweeper.integration.spec.js#expires
        the lapsed grants of both tenants, oldest expiry first, and counts what it did
      - >-
        services-commerce:modules/entitlements/tests/integration/services/register/entitlement-sweeper.integration.spec.js#leaves
        a grant inside its window, one with no window and a revoked one alone
      - TST-COM-ORD-068
    provenance: test
    source: >-
      services-commerce:modules/entitlements/tests/integration/services/register/entitlement-sweeper.integration.spec.js#expires
      the lapsed grants of both tenants, oldest expiry first, and counts what it did
    category: transition
    expected_provenance: test
    expected_source: >-
      services-commerce:modules/entitlements/tests/integration/services/register/entitlement-sweeper.integration.spec.js#expires
      the lapsed grants of both tenants, oldest expiry first, and counts what it did
  - id: ATS-COM-ORD-013-10
    title: Rights access separates holders from staff readers
    level: api
    proves:
      - BR-CAP-COM-ORD-013-10
    preconditions: 'The fixtures provide a holder, another member and a console reader.'
    steps:
      - do: Read by holder and order and attempt restoration.
        provenance: test
        source: >-
          services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#shows a stranger nothing
          of the member’s, and refuses the member’s grant by id 403
    expected: >-
      The authorized reads succeed, another member cannot reach the right and restoration requires staff
      authority.
    negative: true
    data_needs: Use the controlled records and transports established by the cited tests.
    bound_to:
      - >-
        services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#shows a stranger nothing of
        the member’s, and refuses the member’s grant by id 403
      - >-
        services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#lets a console reader read
        the member’s grants by holder and by order, and refuses them the restore
      - >-
        services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#refuses a portal member the
        restore, and a restore with no Idempotency-Key 400
      - TST-COM-ORD-061
    provenance: test
    source: >-
      services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#shows a stranger nothing of
      the member’s, and refuses the member’s grant by id 403
    category: permission
    expected_provenance: test
    expected_source: >-
      services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#shows a stranger nothing of
      the member’s, and refuses the member’s grant by id 403
  - id: ATS-COM-ORD-013-11
    title: Revocation immediately removes eligibility and consumption access
    category: interaction
    level: api
    proves:
      - BR-CAP-COM-ORD-013-12
    preconditions: A manually granted right is visible to eligibility and has unused allowance.
    steps:
      - do: Revoke the right and read eligibility and consumption before an expiry pass.
        provenance: test
        source: >-
          services-commerce:modules/entitlements/tests/integration/services/entitlements/entitlement-interventions.integration.spec.js#takes
          it out of the Eligibility view and the consume function at once
    expected: The right is absent from eligibility and cannot be consumed.
    negative: false
    data_needs: Use an isolated workspace with the records and responses named in the preconditions.
    bound_to:
      - >-
        services-commerce:modules/entitlements/tests/integration/services/entitlements/entitlement-interventions.integration.spec.js#takes
        it out of the Eligibility view and the consume function at once
      - TST-COM-ORD-064
    provenance: test
    source: >-
      services-commerce:modules/entitlements/tests/integration/services/entitlements/entitlement-interventions.integration.spec.js#takes
      it out of the Eligibility view and the consume function at once
    expected_provenance: test
    expected_source: >-
      services-commerce:modules/entitlements/tests/integration/services/entitlements/entitlement-interventions.integration.spec.js#takes
      it out of the Eligibility view and the consume function at once
  - id: ATS-COM-ORD-013-12
    title: Competing consumers cannot overspend the remaining allowance
    category: concurrency
    level: api
    proves:
      - BR-CAP-COM-ORD-013-05
      - INV-DOM-COM-ORD-004-02
    preconditions: A finite grant has two uses left and two database connections each request both.
    steps:
      - do: 'Hold the first draw while the second waits, then commit the first.'
        provenance: test
        source: >-
          services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#gives the member a link
          and consumes one use per Idempotency-Key (the retry free), then refuses the third 409
          insufficient_entitlement
    expected: The first owns the two uses and the second is refused with no extra use rows.
    negative: false
    data_needs: Use an isolated workspace with the records and responses named in the preconditions.
    bound_to:
      - >-
        services-commerce:modules/entitlements/tests/integration/services/persistence/entitlements.integration.spec.js#lets
        the first draw the two left
      - >-
        services-commerce:modules/entitlements/tests/integration/services/persistence/entitlements.integration.spec.js#refuses
        the second once the first committed, and the ledger holds exactly the first’s uses
      - TST-COM-ORD-066
    provenance: test
    source: >-
      services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#gives the member a link and
      consumes one use per Idempotency-Key (the retry free), then refuses the third 409
      insufficient_entitlement
    expected_provenance: test
    expected_source: >-
      services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#gives the member a link and
      consumes one use per Idempotency-Key (the retry free), then refuses the third 409
      insufficient_entitlement
  - id: ATS-COM-ORD-013-13
    title: Enforcement restoration distinguishes an elapsed grant
    category: transition
    level: api
    proves:
      - BR-CAP-COM-ORD-013-09
      - INV-DOM-COM-ORD-004-04
    preconditions: 'Line grants carry enforcement and unrelated revocation reasons, including an elapsed window.'
    steps:
      - do: Reinstate only the enforcement-revoked grants.
        provenance: test
        source: >-
          services-commerce:modules/entitlements/tests/integration/services/register/entitlement-sweeper.integration.spec.js#expires
          the lapsed grants of both tenants, oldest expiry first, and counts what it did
    expected: >-
      The eligible enforcement grant becomes active, its elapsed counterpart becomes expired and the unrelated
      revocation remains.
    negative: false
    data_needs: Use an isolated workspace with the records and responses named in the preconditions.
    bound_to:
      - >-
        services-commerce:modules/entitlements/tests/integration/services/persistence/entitlements.integration.spec.js#reinstates
        only what the named reason revoked, and expires a reinstated grant whose window has passed
      - TST-COM-ORD-066
    provenance: test
    source: >-
      services-commerce:modules/entitlements/tests/integration/services/register/entitlement-sweeper.integration.spec.js#expires
      the lapsed grants of both tenants, oldest expiry first, and counts what it did
    expected_provenance: test
    expected_source: >-
      services-commerce:modules/entitlements/tests/integration/services/register/entitlement-sweeper.integration.spec.js#expires
      the lapsed grants of both tenants, oldest expiry first, and counts what it did
  - id: ATS-COM-ORD-013-14
    title: Cancellation revokes the purchased right without removing use history
    category: interaction
    level: api
    proves:
      - BR-CAP-COM-ORD-013-08
      - BR-CAP-COM-ORD-014-04
    preconditions: A completed purchased grant has one recorded use.
    steps:
      - do: Cancel its line and retry the buyer’s download.
        provenance: proposed
        source:
          - >-
            services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#revokes the line’s grant
            with the reason, refuses the download 409 entitlement_not_active, and writes the history
          - >-
            services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#is delivered by the worker to
            the participant’s cancel, which settles the document completed and runs the refund after the
            domain (ADR-13)
    expected: 'The grant is revoked, the original use remains and the download is refused.'
    negative: true
    data_needs: Use an isolated workspace with the records and responses named in the preconditions.
    bound_to: []
    provenance: proposed
    source:
      - >-
        services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#revokes the line’s grant
        with the reason, refuses the download 409 entitlement_not_active, and writes the history
      - >-
        services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#is delivered by the worker to the
        participant’s cancel, which settles the document completed and runs the refund after the domain
        (ADR-13)
    exercises:
      - CAP-COM-ORD-013
      - CAP-COM-ORD-014
    related_capabilities:
      - CAP-COM-ORD-014
    expected_provenance: proposed
    expected_source:
      - >-
        services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#revokes the line’s grant
        with the reason, refuses the download 409 entitlement_not_active, and writes the history
      - >-
        services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#is delivered by the worker to the
        participant’s cancel, which settles the document completed and runs the refund after the domain
        (ADR-13)
  - id: ATS-COM-ORD-013-15
    title: A purchased grant can be used before a cancellation revokes it
    category: interaction
    level: api
    proves:
      - BR-CAP-COM-ORD-013-01
      - BR-CAP-COM-ORD-012-01
      - BR-CAP-COM-ORD-014-01
    preconditions: An application freezes a finite grant on a purchased line.
    steps:
      - do: 'Deliver the grant, consume once, restore that use and cancel the line.'
        provenance: proposed
        source:
          - 'services-commerce:modules/entitlements/services/register/grant-handler.ts'
          - >-
            services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#delivered the obligation
            to the register: completed, with the grant as its record
          - >-
            services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#gives two downloads and
            refuses the third 409 insufficient_entitlement
          - >-
            services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#restores use 1 (an
            intervention: the log row, the history, the audit event), replays under the same key, refuses the
            same use under another
          - 'services-commerce:modules/fulfillment/services/register/intervention-audit.ts'
          - 'services-commerce:modules/entitlements/services/register/revocation.ts'
          - 'services-commerce:modules/entitlements/services/register/entitlement-sweeper.ts'
    expected: History retains the use and restoration while later consumption is refused after cancellation.
    negative: false
    data_needs: Use an isolated workspace with the records and responses named in the preconditions.
    bound_to: []
    provenance: proposed
    source:
      - 'services-commerce:modules/entitlements/services/register/grant-handler.ts'
      - >-
        services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#delivered the obligation to
        the register: completed, with the grant as its record
      - >-
        services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#gives two downloads and
        refuses the third 409 insufficient_entitlement
      - >-
        services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#restores use 1 (an
        intervention: the log row, the history, the audit event), replays under the same key, refuses the same
        use under another
      - 'services-commerce:modules/fulfillment/services/register/intervention-audit.ts'
      - 'services-commerce:modules/entitlements/services/register/revocation.ts'
      - 'services-commerce:modules/entitlements/services/register/entitlement-sweeper.ts'
    exercises:
      - CAP-COM-ORD-013
      - CAP-COM-ORD-012
      - CAP-COM-ORD-014
    workflows:
      - WF-COM-ORD-009
    expected_provenance: proposed
    expected_source:
      - 'services-commerce:modules/entitlements/services/register/grant-handler.ts'
      - >-
        services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#delivered the obligation to
        the register: completed, with the grant as its record
      - >-
        services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#gives two downloads and
        refuses the third 409 insufficient_entitlement
      - >-
        services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#restores use 1 (an
        intervention: the log row, the history, the audit event), replays under the same key, refuses the same
        use under another
      - 'services-commerce:modules/fulfillment/services/register/intervention-audit.ts'
      - 'services-commerce:modules/entitlements/services/register/revocation.ts'
      - 'services-commerce:modules/entitlements/services/register/entitlement-sweeper.ts'
evidence:
  - >-
    Examined reference: services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#delivered
    the obligation to the register: completed, with the grant as its record
  - >-
    Examined reference: services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#gives the
    member a link and consumes one use per Idempotency-Key (the retry free), then refuses the third 409
    insufficient_entitlement
  - >-
    Examined reference: services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#gives two
    downloads and refuses the third 409 insufficient_entitlement
  - >-
    Examined reference: services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#grants ONE
    download right of two uses for the three copies, not six
  - >-
    Examined reference: services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#lets a
    console reader read the member’s grants by holder and by order, and refuses them the restore
  - >-
    Examined reference: services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#lets the
    member download once more, and no more
  - >-
    Examined reference: services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#placed the
    e-book with a plan of the register’s own kind and the download specification frozen on the line
  - >-
    Examined reference: services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#refuses a
    portal member the restore, and a restore with no Idempotency-Key 400
  - >-
    Examined reference: services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#restores use
    1 (an intervention: the log row, the history, the audit event), replays under the same key, refuses the
    same use under another
  - >-
    Examined reference: services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#revokes the
    line’s grant with the reason, refuses the download 409 entitlement_not_active, and writes the history
  - >-
    Examined reference: services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#shows a
    stranger nothing of the member’s, and refuses the member’s grant by id 403
  - >-
    Examined reference:
    services-commerce:modules/entitlements/tests/integration/services/entitlements/entitlement-interventions.integration.spec.js#moves
    it to revoked with the staff reason, the used quantity standing
  - >-
    Examined reference:
    services-commerce:modules/entitlements/tests/integration/services/entitlements/entitlement-interventions.integration.spec.js#refuses
    a second revoke 409 entitlement_not_revocable, logging nothing more
  - >-
    Examined reference:
    services-commerce:modules/entitlements/tests/integration/services/entitlements/entitlement-interventions.integration.spec.js#refuses
    a window that ends before it starts, writing neither the grant nor the intervention
  - >-
    Examined reference:
    services-commerce:modules/entitlements/tests/integration/services/entitlements/entitlement-interventions.integration.spec.js#revokes
    it whatever its source, with the intervention and the revocation on the order’s history
  - >-
    Examined reference:
    services-commerce:modules/entitlements/tests/integration/services/entitlements/entitlement-interventions.integration.spec.js#writes
    a manual grant with no order, line or obligation, the window stated, the reason in its notes
  - >-
    Examined reference:
    services-commerce:modules/entitlements/tests/integration/services/register/entitlement-sweeper.integration.spec.js#expires
    the lapsed grants of both tenants, oldest expiry first, and counts what it did
  - >-
    Examined reference:
    services-commerce:modules/entitlements/tests/integration/services/register/entitlement-sweeper.integration.spec.js#leaves
    a grant inside its window, one with no window and a revoked one alone
  - >-
    Examined reference:
    services-commerce:modules/entitlements/tests/integration/services/register/grant-handler.integration.spec.js#fails
    the obligation of a purchase that names no specification, not retryable, with obligation_failed raised
  - >-
    Examined reference:
    services-commerce:modules/entitlements/tests/unit/register/grant-specification.spec.js#gives the grant to
    the line’s recipient, to the buyer when the line names none, and to the buyer when the spec says so
coverage:
  rule: covered
  transition: 'gap: FND-COM-ORD-070'
  validation: 'gap: FND-COM-ORD-070'
  permission: 'gap: FND-COM-ORD-070'
  edge: covered
  failure: covered
  boundary: 'gap: FND-COM-ORD-070'
  concurrency: covered
  invariant: 'gap: FND-COM-ORD-070'
  interaction: covered
coverage_definition: Covered means a design scenario exists; executable coverage and execution results are separate.
permission_coverage:
  - key: commerce.entitlements.read
    where_checked: api
    scenarios:
      - ATS-COM-ORD-013-07
      - ATS-COM-ORD-013-10
    gap: FND-COM-ORD-070
    note: >-
      The listed examples do not establish a complete allow-and-deny matrix for this key; unused catalogue
      keys need no invented route.
    provenance: unknown
    source: FND-COM-ORD-070
  - key: commerce.entitlements.restore
    where_checked: api
    scenarios:
      - ATS-COM-ORD-013-07
      - ATS-COM-ORD-013-10
    gap: FND-COM-ORD-070
    note: >-
      The listed examples do not establish a complete allow-and-deny matrix for this key; unused catalogue
      keys need no invented route.
    provenance: unknown
    source: FND-COM-ORD-070
  - key: commerce.entitlements.grant
    where_checked: api
    scenarios:
      - ATS-COM-ORD-013-07
      - ATS-COM-ORD-013-10
    gap: FND-COM-ORD-070
    note: >-
      The listed examples do not establish a complete allow-and-deny matrix for this key; unused catalogue
      keys need no invented route.
    provenance: unknown
    source: FND-COM-ORD-070
  - key: commerce.entitlements.revoke
    where_checked: api
    scenarios:
      - ATS-COM-ORD-013-07
      - ATS-COM-ORD-013-10
    gap: FND-COM-ORD-070
    note: >-
      The listed examples do not establish a complete allow-and-deny matrix for this key; unused catalogue
      keys need no invented route.
    provenance: unknown
    source: FND-COM-ORD-070
transition_coverage:
  - state_model: STATE-COM-ORD-008
    from: active
    to: revoked
    trigger: 'A cancellation, enforcement suspension or reasoned staff action revokes availability.'
    scenarios:
      - ATS-COM-ORD-013-08
    provenance: test
    source: >-
      services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#revokes the line’s grant with
      the reason, refuses the download 409 entitlement_not_active, and writes the history
    note: The cited test exercises this transition; other transitions retain separate gaps.
  - state_model: STATE-COM-ORD-008
    from: revoked
    to: active
    trigger: Enforcement restoration revisits its own revocation.
    scenarios: []
    gap: FND-COM-ORD-070
    provenance: unknown
    source: 'services-commerce:modules/entitlements/services/register/grant-handler.ts:enforceForObligation'
    note: 'Individual examples do not exhaustively prove this transition, its guard and side effects.'
  - state_model: STATE-COM-ORD-008
    from: revoked
    to: expired
    trigger: Restoration finds the previously enforced grant beyond its validity end.
    scenarios: []
    gap: FND-COM-ORD-070
    provenance: unknown
    source: 'services-commerce:modules/entitlements/services/register/grant-handler.ts:enforceForObligation'
    note: 'Individual examples do not exhaustively prove this transition, its guard and side effects.'
  - state_model: STATE-COM-ORD-008
    from: active
    to: expired
    trigger: The expiry pass finds an active grant past its end.
    scenarios: []
    gap: FND-COM-ORD-070
    provenance: unknown
    source: 'services-commerce:modules/entitlements/services/register/entitlement-sweeper.ts:sweepEntitlements'
    note: 'Individual examples do not exhaustively prove this transition, its guard and side effects.'
invariant_coverage:
  - invariant: INV-DOM-COM-ORD-004-01
    scenarios: []
    gap: FND-COM-ORD-070
    provenance: unknown
    source: >-
      services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#grants ONE download right of
      two uses for the three copies, not six
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-004-02
    scenarios:
      - ATS-COM-ORD-013-12
    gap: FND-COM-ORD-070
    provenance: unknown
    source: 'services-commerce:modules/entitlements/db/entitlements.table.ts:entitlements_quantity_check'
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-004-03
    scenarios: []
    gap: FND-COM-ORD-070
    provenance: unknown
    source: >-
      services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#gives the member a link and
      consumes one use per Idempotency-Key (the retry free), then refuses the third 409
      insufficient_entitlement
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-004-04
    scenarios:
      - ATS-COM-ORD-013-13
    gap: FND-COM-ORD-070
    provenance: unknown
    source: 'services-commerce:db/migrations/20261018130023_entitlements.sql:consume_entitlement'
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-004-05
    scenarios: []
    gap: FND-COM-ORD-070
    provenance: unknown
    source: >-
      services-commerce:modules/entitlements/db/entitlements.table.ts:entitlements_revocation_check,
      entitlements_expiry_check
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-004-06
    scenarios: []
    gap: FND-COM-ORD-070
    provenance: unknown
    source: >-
      services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#revokes it with the reason
      (the used quantity standing), replays the revoke under its key, refuses another 409
      entitlement_not_revocable
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-004-07
    scenarios: []
    gap: FND-COM-ORD-070
    provenance: unknown
    source: 'services-commerce:modules/entitlements/services/persistence/entitlement-uses.ts'
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-004-08
    scenarios: []
    gap: FND-COM-ORD-070
    provenance: unknown
    source: 'services-commerce:modules/entitlements/db/entitlements.table.ts:entitlements_validity_check'
    note: Broader invariant coverage remains open beyond the concrete examples.
  - invariant: INV-DOM-COM-ORD-004-09
    scenarios: []
    gap: FND-COM-ORD-070
    provenance: unknown
    source: >-
      services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#shows a stranger nothing of
      the member’s, and refuses the member’s grant by id 403
    note: Broader invariant coverage remains open beyond the concrete examples.
workflow_coverage:
  - workflow: WF-COM-ORD-006
    scenarios:
      - ATS-COM-ORD-001-20
    gap: FND-COM-ORD-070
    provenance: proposed
    source:
      - 'services-commerce:modules/checkout/aws/lambda/SWEEPER.ts:handler'
      - 'services-commerce:modules/orders/services/reservations/reservation-sweeper.ts:sweepReservations'
      - 'services-commerce:modules/orders/services/orders/tender-window-sweeper.ts:sweepTenderWindows'
      - 'services-commerce:modules/checkout/aws/lambda/SWEEPER.ts:handler'
      - 'services-commerce:modules/orders/services/orders/financial-sweeps.ts:sweepFinancials'
      - 'services-commerce:modules/entitlements/services/register/entitlement-sweeper.ts:sweepEntitlements'
      - 'services-commerce:modules/checkout/aws/lambda/SWEEPER.ts:handler'
  - workflow: WF-COM-ORD-009
    scenarios:
      - ATS-COM-ORD-013-15
    gap: FND-COM-ORD-070
    provenance: proposed
    source:
      - 'services-commerce:modules/entitlements/services/register/grant-handler.ts'
      - >-
        services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#delivered the obligation to
        the register: completed, with the grant as its record
      - >-
        services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#gives two downloads and
        refuses the third 409 insufficient_entitlement
      - >-
        services-commerce:modules/entitlements/tests/e2e/entitlements.e2e.spec.js#restores use 1 (an
        intervention: the log row, the history, the audit event), replays under the same key, refuses the same
        use under another
      - 'services-commerce:modules/fulfillment/services/register/intervention-audit.ts'
      - 'services-commerce:modules/entitlements/services/register/revocation.ts'
      - 'services-commerce:modules/entitlements/services/register/entitlement-sweeper.ts'
  - workflow: WF-COM-ORD-010
    scenarios:
      - ATS-COM-ORD-014-19
    gap: FND-COM-ORD-070
    provenance: proposed
    source:
      - >-
        services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#refuses a placed order 409
        order_not_cancellable, another member 403 not_your_party, a reader 403 permission_missing, another
        tenant 404
      - >-
        services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#refuses a member on the console
        approve route 403, and a clerk approving 403 permission_missing
      - >-
        services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#fences a DELIVERED seat through
        the participant’s commerce_claim_cancellation, and the participant’s cancel gives the capacity back
      - 'services-commerce:modules/orders/services/cancellations/cancellation-workflow.ts'
      - >-
        services-commerce:modules/orders/services/cancellations/cancellation-settlement.ts:settleCancellationAfterObligation
      - >-
        services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#raises the fee invoice, applies
        the freed money to it and refunds the remainder
      - >-
        services-commerce:modules/orders/tests/e2e/cancellations.e2e.spec.js#shows the cancellation’s credit
        on the order’s money mirror at once, read right after the cancel
interaction_coverage:
  - with: CAP-COM-ORD-014
    scenarios:
      - ATS-COM-ORD-013-14
unproved_rules: []
---

# Provide purchased rights and account for their use: Capability Test Specification

## Coverage

| Rule | Scenario or finding |
|---|---|
| `BR-CAP-COM-ORD-013-01` | `ATS-COM-ORD-013-01`, `ATS-COM-ORD-013-15` |
| `BR-CAP-COM-ORD-013-02` | `ATS-COM-ORD-013-02` |
| `BR-CAP-COM-ORD-013-03` | `ATS-COM-ORD-013-03` |
| `BR-CAP-COM-ORD-013-04` | `ATS-COM-ORD-013-04` |
| `BR-CAP-COM-ORD-013-05` | `ATS-COM-ORD-013-05`, `ATS-COM-ORD-013-12` |
| `BR-CAP-COM-ORD-013-06` | `ATS-COM-ORD-013-06` |
| `BR-CAP-COM-ORD-013-07` | `ATS-COM-ORD-013-07` |
| `BR-CAP-COM-ORD-013-08` | `ATS-COM-ORD-013-08`, `ATS-COM-ORD-013-14` |
| `BR-CAP-COM-ORD-013-09` | `ATS-COM-ORD-013-09`, `ATS-COM-ORD-013-13` |
| `BR-CAP-COM-ORD-013-10` | `ATS-COM-ORD-013-10` |
| `BR-CAP-COM-ORD-013-12` | `ATS-COM-ORD-013-11` |

## Interactions With Related Capabilities

Cancellation revokes the purchased right without removing use history. A completed purchased grant has one recorded use. Cancel its line and retry the buyer’s download.

Crossing workflow examples also cover preparation, commitment and recovery at their service handoffs. Their structured bindings distinguish specified outcomes from executable evidence.
