---
id: WF-COM-FUL-008
title: Re-freeze waiting gates to a changed policy
trigger: Staff apply a policy with its required reason.
product_area: commerce
module: fulfillment
revision: 1
status: draft
design_intent: proposed
implementation_evidence: observed
inference: []
source_sha:
  services-commerce: c8b66a98e2490617aec38ba5c8165dd9bd0a8f9b
implements:
  - CAP-COM-FUL-001
moves:
  - STATE-COM-FUL-001
crosses:
  - SVC-COM-FUL-fulfillment
idempotency: >-
  Matching gates are skipped. The response reports examination and changed
  records, but repetition rereads the first page and does not establish progress
  through a large scope.
concurrency: >-
  Gate replacement conditionally requires the obligation still pending.
  Authorization or blocking that wins first excludes that obligation from
  replacement.
hops:
  - 'n': 1
    actor_or_service: Fulfillment API
    action: >-
      Record a policy-application intervention and staff reason against the
      policy.
    anchor: >-
      services-commerce:modules/fulfillment/services/policies/retroactive-policy.ts:applyPolicyRetroactively
    seam: sync
    on_failure: Reject missing reason or apply authority.
    left_inconsistent: A refused intervention makes no change.
    observer: Staff intervention ledger.
    provenance: test
    source: >-
      services-commerce:modules/fulfillment/tests/e2e/fulfillment-policies.e2e.spec.js#re-freezes
      the pending obligation to the replaced policy with a receipt, records the
      intervention, and re-freezes nothing on a repeat
  - 'n': 2
    actor_or_service: Policy application
    action: Read the first bounded pending page covered by the policy scope.
    anchor: >-
      services-commerce:modules/fulfillment/services/persistence/obligations.ts:listPendingObligationsOfScope
    seam: sync
    on_failure: Return request failure.
    left_inconsistent: Changes from earlier calls remain stored.
    observer: Application response receipt.
    provenance: observed
    source: >-
      services-commerce:modules/fulfillment/services/persistence/obligations.ts:listPendingObligationsOfScope
  - 'n': 3
    actor_or_service: Policy application
    action: >-
      Resolve present selection, retain frozen approval and readiness, replace
      differing gates and clear their evaluation timestamps.
    anchor: >-
      services-commerce:modules/fulfillment/services/persistence/obligations.ts:refreezeGate
    seam: sync
    on_failure: >-
      Return failure after any earlier per-obligation commits; replay can reread
      the same page indefinitely.
    left_inconsistent: Only part of the first page may have changed.
    observer: Gate replacement history.
    provenance: documented
    source: 'services-commerce:docs/migrations/obligation-register/README.md#D-P4-05'
  - 'n': 4
    actor_or_service: Register sweep
    action: >-
      Leave changed pending gates to the bounded sweep after its inactivity
      threshold.
    anchor: >-
      services-commerce:modules/fulfillment/services/register/register-sweeper.ts:sweepRegister
    seam: schedule
    on_failure: Use later successful scans without a deadline guarantee.
    left_inconsistent: Replaced conditions can remain unevaluated.
    observer: Retained gate verdicts.
    provenance: observed
    source: >-
      services-commerce:modules/fulfillment/services/policies/retroactive-policy.ts
branches:
  - 'Authorized and later obligations, and blocked ones, are does not re-frozen.'
waits:
  - The next call for a subsequent page.
evidence:
  - >-
    services-commerce at c8b66a98:
    modules/fulfillment/services/policies/retroactive-policy.ts;
    services/persistence/obligations.ts;
    docs/migrations/obligation-register/README.md (D-P4-05, D-P4-06).
controls: [TC-IAM-006, 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-DAT-001, TC-DAT-002, TC-DAT-003, TC-LOG-001, TC-LOG-002, TC-LOG-003, TC-LOG-004, TC-LOG-005, TC-AVL-004, 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]
---

# Re-Freeze Waiting Gates to a Changed Policy

## What It Does

Staff policy application records a reason and inspects a bounded page of pending records in scope. It resolves current policy selection, retains frozen safeguards and replaces only differing gates. Changed evaluation timestamps leave those gates for later sweep evaluation.

## The Flow

```mermaid
sequenceDiagram
  participant S as Administrator
  participant F as Fulfillment API
  participant O as Obligations
  participant W as Sweep
  S->>F: apply policy, reason
  F->>F: record intervention
  F->>O: read a page of pending obligations
  F->>O: re-freeze those that differ
  F-->>S: receipt: examined, re-frozen, more
  W->>O: bounded pending evaluation after inactivity
```

## When Something Fails

Earlier gate replacements remain committed if later work fails. Repetition reads the first page again, so unchanged records can obstruct later records. Neither repeated calls nor the sweep provides a fixed completion deadline.
