---
id: WF-MBR-MEM-006
title: Write a package's grants in the committing transaction
trigger: 'A committed package period contains configured grants, including on renewal.'
product_area: membership
module: memberships
revision: 1
status: draft
design_intent: proposed
implementation_evidence: observed
inference: []
source_sha:
  services-membership: 5994c270e8a37a30f848e99ba5b5ee6b87c08893
  react-console: baf6dae382d6f41dce976c7f848667ccc37e076f
implements:
  - CAP-MBR-MEM-006
moves:
  - STATE-MBR-MEM-003
crosses:
  - SVC-MBR-MEM-memberships
  - SVC-MBR-MEM-commerce-participant
idempotency: >-
  The planner skips effective target coverage that overlaps a proposed grant.
  Source commitment and term uniqueness prevent duplicate application through
  the normal committing paths.
concurrency: >-
  Grant writes share the source transaction and acquire each target membership
  lock before inserting coverage.
hops:
  - 'n': 1
    actor_or_service: Memberships service
    action: >-
      Calculate non-self grants using copied source dates or each grant’s own
      rule, with no start before the source.
    anchor: >-
      services-membership:modules/memberships/services/grants/grant-plan.ts:grantPlanOf
    seam: sync
    on_failure: Failure aborts the transaction containing the source period.
    left_inconsistent: No partial local change remains.
    observer: Calling operation result
    provenance: test
    source: >-
      services-membership:modules/memberships/tests/unit/grant-plan.spec.ts#plans
      a granted term by the grant’s own rule, never starting before the primary
      term
  - 'n': 2
    actor_or_service: Memberships service
    action: >-
      Find or establish the owner’s principal target holding and insert a
      source-linked term for each non-overlapping grant.
    anchor: >-
      services-membership:modules/memberships/services/grants/apply-grants.ts:applyPackageGrants
    seam: sync
    on_failure: An error aborts the transaction and reverses its writes.
    left_inconsistent: No partial local change remains.
    observer: Caller result including generated and skipped grants
    provenance: observed
    source: >-
      services-membership:modules/memberships/services/grants/apply-grants.ts:applyPackageGrants
  - 'n': 3
    actor_or_service: Memberships service
    action: Publish commitment for the granted period and refresh its holding caches.
    anchor: >-
      services-membership:modules/memberships/services/operations/term-writes.ts:writeCommittedTerm
    seam: sync
    on_failure: An error aborts the transaction and reverses its writes.
    left_inconsistent: No partial local change remains.
    observer: Published business-event log
    provenance: observed
    source: >-
      services-membership:modules/memberships/services/operations/term-writes.ts:writeCommittedTerm
branches:
  - Self-program grants are omitted from the grant plan.
waits: []
evidence:
  - >-
    services-membership at 5994c270:
    modules/memberships/services/grants/apply-grants.ts, grant-plan.ts;
    tests/acceptance/memberships/MBR-ACC-0181.acceptance.ts
controls: [TC-AVL-002, TC-AVL-003, TC-AVL-004, TC-AZ-001, TC-AZ-002, TC-AZ-003, TC-AZ-004, TC-AZ-006, TC-CHG-001, TC-CHG-002, TC-CHG-003, TC-CHG-004, TC-CRY-001, TC-CRY-002, TC-CRY-003, TC-DAT-001, TC-DAT-002, TC-DAT-003, TC-DAT-007, TC-IAM-001, TC-IAM-002, TC-IAM-004, TC-IAM-005, TC-IAM-006, TC-LOG-002, TC-LOG-003, TC-LOG-004, TC-LOG-005, TC-MON-001, TC-MON-002, TC-MON-004, TC-PI-001, TC-PI-002, TC-PI-003, TC-PI-004, TC-PI-005, TC-PRV-001, TC-PRV-002, TC-SEC-001, TC-SEC-004, TC-TEN-001, TC-TEN-002, TC-TEN-003]
---

# Write a package's grants in the committing transaction

## What It Does

Package commitment can create additional program coverage for the same owner. Each planned grant links to the source period so later correction or closure can find it.

## The Flow

```mermaid
flowchart TD
  H1["Calculate non-self grants using copied source dates or each grant’s own rule, with no start before the source"]
  H2["Find or establish the owner’s principal target holding and insert a source-linked term for each non-overlapping grant"]
  H1 --> H2
  H3["Publish commitment for the granted period and refresh its holding caches"]
  H2 --> H3
```

## When Something Fails

Any failing grant write rolls back the source commitment. Existing effective coverage is reported as skipped rather than failing the source. Deleting a source can detach the linked grant, as an existing finding records.
