Economics approved; rewards, caps, expiration, and pending policy reviewed.
Launch, observe, reconcile, and recover.
Use production gates, retry rules, signed webhooks, reconciliation checks, and incident runbooks built for loyalty liabilities.
Production is a controlled change.
Customer mapping, consent status, duplicates, and deletion process tested.
Earn, retry, full return, partial return, and out-of-order behavior proven.
Opening balances and liability control totals reconciled with signed approval.
Least-privilege production keys stored, rotated, and monitored server-side.
Alerts, owners, webhook replay, rollback, and customer support scripts ready.
Quiet programs still need expiration, retry, and cleanup work.
The checked-in worker asks for a bounded maintenance sweep every minute and after normal API traffic. D1 grants a durable per-environment lease so overlapping workers do not own the same sweep.
- 1
Set a dedicated secret
MAINTENANCE_SECRETis required, server-only, at least 32 characters, non-placeholder, and separate from every public API or privacy key. Without it, the worker safely does no maintenance work. - 2
Trigger two ways
The source config declares
* * * * *; ordinary API traffic also schedules the same sweep asynchronously. These paths may overlap. - 3
Lease, page, then resume
D1 chooses at most four due environments per sweep. Each environment gets a fresh owner token and a three-minute heartbeat lease, processes one bounded keyset page, and stores its phase and cursor. Every write is fenced by that token. Remaining cycle work becomes eligible after one second; a completed idle cycle waits one minute.
- 4
Inspect evidence
The lease stores last start, last successful completion, bounded last error, and resumable checkpoint. Operators still need external alerts and a deployment-specific runbook.
Bounded leased sweep
- Per-minute scheduled trigger
- API-traffic-triggered sweep
- D1 per-environment lease
- Reservation and point expiry, webhook retry, and cleanup dispatch
Operating reliability
- Deployed cron uptime
- External monitoring and paging
- Maximum processing or delivery time
- Contractual SLA, RPO/RTO, restore, or DR evidence
Verify the bytes before trusting the event.
Loyumi deliveries use x-loyumi-event-id, x-loyumi-timestamp, and x-loyumi-signature: v1=<hex>. Existing integrations may continue reading the legacy x-loyaltyos-* aliases during the compatibility window.
- 1
Read the raw body
Do not parse and re-serialize before verification.
- 2
Reject stale timestamps
Apply a short replay window that matches your risk policy and tolerate normal clock skew.
- 3
Compute the expected signature
HMAC-SHA256 the UTF-8 string
timestamp.raw_bodywith the endpoint secret. - 4
Compare in constant time
Only enqueue trusted events. Deduplicate by event ID and respond quickly.
expected = HMAC_SHA256(
endpoint_secret,
x_loyumi_timestamp + "." + raw_request_body
)
constant_time_compare("v1=" + hex(expected), x_loyumi_signature)Retry transport failures, not business decisions.
Retry-After; keep the same key and body.requestId.Compare three independent views.
Completed and returned order value by source reference.
Issued, clawed back, expired, redeemed, pending, and available points.
Opening, movement, closing liability, and documented adjustments.
Contain first. Preserve evidence. Recover deliberately.
Disable the affected key, endpoint, campaign, or production path without deleting evidence.
Bound environments, programs, members, source references, point value, and customer impact.
Assign incident, finance, risk, engineering, support, and communications owners.
Use replay-safe requests or authorized ledger adjustments; reconcile before reopening.
Document cause, detection gap, control improvement, and evidence that the fix works.