# Upgrading to 1.2.0

This page lists what changed since the previous release; see the [upgrade procedure](README.md).

## @openlup/core

### Changed

- Document the source starter's owned language registry, configured default and named startup copy refusals. The current platform language set remains `en` and `pl`.

Migration: Existing source-starter adopters add `market.defaultLocale` and compose the owned `market` registry from `owned/market.config.ts`. Keep `locales: ['en', 'pl']` and `defaultLocale: 'en'` for the previous demonstration behavior. This documentation change adds no npm API or SQL migration.

### Starter applications from 1.1.0

Migration: Follow the [starter upgrade order](README.md#starter-upgrade-order),
including [ownership inventory reconciliation](README.md#reconcile-a-customized-ownership-inventory)
if you customized the inventory. Reconcile the owned files below against the
separate target extraction before applying managed files. Add
`owned/market.config.ts` **only to the target snapshot**, using that extraction's
exact bytes; it is a new owned file,
not a newly managed customization. The upgrade CLI then creates it with the
usual conflict refusal, interruption recovery and replay behavior. Leave every
other owned path out of both snapshots. After creation, keep the market file
application-owned and outside future managed snapshots.

For each uncustomized file in this table, take the target extraction's bytes
before applying managed files. For customized files, preserve local values and
apply the reconciliation described below. Do not overwrite a customized file
with the demonstration defaults.
Compare the inputs your owned policy accepts before and after the upgrade so your store keeps its existing rules unless you decide to change them.

| Owned path | Reconciliation |
| --- | --- |
| `AGENTS.md` | Merge the target's task routes, representation bounds and explicit inventory-policy installation guidance into local contributor instructions. |
| `owned/renewal.config.ts` | Add account actions and pause choices; use the configured default locale for notices. |
| `owned/store.config.ts` | Add subscription creation, the installed inventory policy and the checkout recovery reminder schedule to every configuration. Compose the locale registry. |
| `owned/acquisition-policy.ts` | Optionally adopt the local address callbacks; the existing callback-free policy remains valid. |
| `owned/copy.ts` | Keep all required application copy keys for each configured locale. |
| `owned/editor-copy.ts` | Keep all editor keys for each configured locale. |
| `owned/quote-copy.ts` | Keep quote and refusal keys for each configured locale and the explicit refusal allowlist. |
| `owned/renewal-copy.ts` | Keep all renewal notice keys, including nested paid-order text, for each configured locale. |
| `owned/demo-seed.ts` | Read product name and description with `config.market.defaultLocale` instead of `.en`. |

`AGENTS.md` is extracted from the source template. Its guidance changes have no
startup refusal of their own; preserve local authority and contribution rules
when reconciling it with the target.

#### Account actions and pause choices

In `demoSubscriptionCare()` in `owned/renewal.config.ts`, add
`subscriptionCare.actions` with all five keys. The target defaults are:

```text
actions: {
  active: ['skip', 'slide', 'order_now', 'pause', 'cancel'],
  paused: ['resume', 'cancel'],
  cancelled: ['reactivate'],
  whilePaymentBlocked: ['pause', 'cancel'],
  whilePaymentExpired: ['cancel', 'resume'],
}
```

Each value is an array without duplicates, containing only `skip`, `slide`,
`order_now`, `pause`, `cancel`, `resume` or `reactivate`; empty arrays disable
actions. Missing keys, unknown keys or invalid arrays refuse startup with
`starter_subscription_actions_invalid`. State admission applies to all actions.
The payment-state allowlists apply to actions other than `reactivate`.
To disable reactivation, remove `reactivate` from `actions.cancelled`.
Native command guards still apply.

Add `subscriptionCare.pausePresets` with
`{ allowed: ['2_weeks', '1_month', 'indefinite'], default: '2_weeks' }`.
The equivalent target helper is `choice('2_weeks', '2_weeks', '1_month', 'indefinite')`
from `shared/policy.ts`. The allowed array must be nonempty, unique and limited
to those three values, and must contain the default. Missing or invalid choices
refuse with `starter_pause_presets_invalid`.

The target also adds `subscriptionCare.retention.pausePreset: '1_month'`.
This member is optional: omission uses `pausePresets.default`. If present, it
must be one of the allowed presets or startup refuses with
`starter_retention_configuration_invalid`. Preserve the existing retention
reason mapping, local timing and three-rung retry ladder.

#### Subscription creation and representation bounds

In every configuration in `owned/store.config.ts`, add
`subscriptionCreation: { editWindowHours: 72 }`, or retain a deliberate local
whole-hour value from 1 through 720. Missing, fractional or out-of-range values
refuse startup with `starter_subscription_creation_invalid`. This is the
initial subscription snapshot's edit window; it does not rewrite existing
subscriptions or replace the separate editing policy.

No owned edit is needed for the target's existing representation defaults.
Check customized offers: `offer.maxUnits` is at most 100, each per-SKU
subscription quantity domain has maximum 99, and
`maximumBaseLines + maximumAddonLines` is at most 50. Violations refuse startup
with `starter_units_above_representation` or
`starter_lines_above_representation`, respectively. The target keeps
`maximumBaseLines: 6`, `maximumAddonLines: 12` and per-SKU quantities 1 through
99; the total `maximumUnits: 1782` is a separate commercial bound.

#### Install the renewal stock policy explicitly

In every configuration in `owned/store.config.ts`, add
`inventory: { renewalProtection: { revision: 'starter-1', renewalProtectionDays: 14 } }`.
A customized policy has exactly `revision` and `renewalProtectionDays`: a
nonblank revision and an integer day count from 1 through 3660. Missing or
invalid policy refuses startup with
`inventory_renewal_protection_policy_invalid`.

After applying the selected platform package's complete native catalogue,
including `20261123130000_inventory_renewal_protection_policy.sql`, in the
[starter upgrade order](README.md#starter-upgrade-order), use a dedicated
write-capable installation connection to explicitly call
`installRenewalStockProtectionPolicy(connection, config.inventory.renewalProtection)`
from `@openlup/platform/inventory` for the configuration being installed.
Read it back with `readRenewalStockProtectionPolicy(connection)` and confirm
both revision and day count before restarting. In the disposable demonstration,
the explicit `./lifecycle up` installation step calls this installer before
the HTTP host starts; application startup itself only reads the installed
policy. Never use the demonstration seed to migrate a customer database.

An absent key reads as `{ revision: 'default', renewalProtectionDays: 14 }`;
even though the days match, it differs from `starter-1`. Startup refuses
`starter_installed_policy_drift` whenever either installed field differs from
the owned policy. Editing a file or applying file snapshots installs no policy.
For later changes, deliberately install the selected revision and days again
with installation authority, verify the readback, then restart.

#### Install the checkout recovery reminder schedule explicitly

In every configuration in a customized `owned/store.config.ts`, preserve local
values and add `checkoutRecoveryReminders` with exactly `revision`,
`abandonedCart` and `checkoutRecovery`. The target uses the historical waves.

```text
checkoutRecoveryReminders: {
  revision: 'starter-1',
  abandonedCart: [
    { stage: 'first', afterHours: 1 },
    { stage: 'gentle', afterHours: 24 },
    { stage: 'last', afterHours: 72 },
  ],
  checkoutRecovery: [
    { stage: 'first', afterHours: 1 },
    { stage: 'last', afterHours: 20 },
  ],
}
```

Use a nonblank revision and a nonempty array for each reminder kind. Each wave
has exactly `stage` and `afterHours`. Use strictly increasing integer hours
from 1 through 2147483647, with unique stages and `last` as the final stage in
each array. `abandonedCart` allows `first`, `gentle` and `last`.
`checkoutRecovery` allows `first` and `last`. Startup and installation refuse
a missing or invalid schedule with `checkout_recovery_reminder_schedule_invalid`.

After applying the target platform package's complete native catalogue,
including `20261123140000_checkout_recovery_reminder_schedule.sql`, in the
[starter upgrade order](README.md#starter-upgrade-order), run the explicit
installation step for the selected configuration. On a dedicated
write-capable installation connection, call
`installCheckoutRecoveryReminderSchedule(connection, config.checkoutRecoveryReminders)`
from `@openlup/platform/commerce/server`. Use
`readCheckoutRecoveryReminderSchedule(connection)` to confirm the revision and
both wave arrays before restarting. In the disposable demonstration,
`./lifecycle up` runs the installer before starting the HTTP host.

Database-backed startup reads the installed schedule and refuses with
`starter_installed_policy_drift` if the revision, stages or hours differ from
the owned configuration. An absent setting uses revision `default`, which
differs from `starter-1` even when the waves match. The managed
`host/paid-mail.ts` selects the recovery subject by stage and retains the
hour-based rule for legacy payloads that have no stage.

#### Update custom native readiness observers

If your custom readiness observer calls the managed `composeNativeBindings`
in the starter's `host/native-composition.ts`, pass the selected `StoreConfig`
as the third argument and the optional keyring as the fourth. The starter
composition uses that configuration to check the installed policies.

#### Locale registry and copy

The new `owned/market.config.ts` exports `market` with
`locales: ['en', 'pl']` and `defaultLocale: 'en'`. After its target-only creation,
a customized application may choose a nonempty unique subset of `en` and `pl`;
the default must be in that subset. Empty or duplicate locales refuse startup
with `starter_locales_invalid`, unsupported languages with
`starter_locale_unsupported`, and a missing or unconfigured default with
`starter_default_locale_invalid`.
Omitting the new file prevents module loading with `ERR_MODULE_NOT_FOUND`.

Import the owned `market` registry into `owned/store.config.ts` and
spread it into every `market` object, preserving local country, currency and
timezone. The target `owned/renewal.config.ts` sets `notices.locale` to
`market.defaultLocale`. A pristine file takes that change; a customized notice
locale may stay when it is in `market.locales`, otherwise notices fall back to
`market.defaultLocale`. Startup refuses unsupported notice locales or country keys
other than two uppercase letters with `starter_renewal_configuration_invalid`.
A country mapping to a platform-supported locale outside `market.locales`
passes startup validation. Notice delivery falls back to `market.defaultLocale`.
For example, mapping a country to `pl` in an English-only registry delivers notices
in English. Keep mappings within `market.locales` by removing or remapping
entries for dropped locales.

Change the two product text reads in
`owned/demo-seed.ts` to `name[config.market.defaultLocale]` and
`description[config.market.defaultLocale]`.

Preserve customized translations in the four copy files above. The target uses
`LocaleCopy` from `shared/locales.ts`; copy, editor and quote key types come
from `shared/copy-keys.ts`, and `RenewalNoticeText` comes from
`shared/renewal-config.ts`. Adopt those typed forms when adapting registries;
keep `CopyKey` exported from `owned/copy.ts` and use `quoteRefusalKeys` for
`isQuoteRefusalCode`, as in the target, so the refusal allowlist is independent
of a translation. Every configured locale must have nonblank strings for the
complete key inventory, including `renewalNoticeCopy`'s `paid` members. Extra
inactive translations may remain. The managed locale test checks coverage and
startup validation and accepts customized wording.

The same requirement applies to localized brand, store, media, product,
recovery message, return/hold choice and acquisition-address labels in owned
data, including `owned/catalogue.ts`, `owned/subscription-editing.ts` and
`owned/acquisition-addresses.ts`, even though those files need no default edit.
Missing or blank text refuses with `starter_locale_copy_missing`, naming its
path and locale. Malformed recovery state/message inventories still refuse
with `starter_recovery_configuration_invalid`.

#### Optional local address callbacks

The target's `savedAddressValidation()` in `owned/acquisition-policy.ts` adds
`local.normalizePostalCode`, `local.isValidPostalCode` and `local.normalizePhone`.
Its fictional defaults remove postal whitespace, accept two uppercase letters
and four digits, and normalize eight local phone digits to `+999` (also
accepting that prefixed form after removing whitespace, parentheses, plus and
hyphens). A customized policy may omit `local` to keep the existing fallback;
there is no new required owned member. If provided, all three callbacks must
be functions or construction refuses with `saved_address_policy_invalid`.
Use the application's own country formats. These callbacks run only when the
selected country resolves to the policy's configured country, including aliases.
Normalization can run more than once per parse. Keep the callbacks deterministic
and effect-free, without I/O, authorization checks or reads of mutable state.
The platform trims and collapses input whitespace and uppercases postal input
before normalization. Postal input and output are bounded to 24 characters and
phone input and local output to 64. Postal normalization must return a
nonempty string and `isValidPostalCode` must return literal `true` to accept;
any other result refuses the field. Return `null` to refuse a supplied phone.
A callback throw refuses the affected field with its configured policy message.

#### Managed tests that pin demonstration values

`test/e4-oms.test.ts` expects the demonstration postal and phone formats.
`test/renewal.test.ts` expects the demonstration account action lists, allowed
pause presets and both pause defaults. `test/address-outcomes.test.ts` matches
the demonstration wording for a change that applies from the next parcel.
`test/acquisition-quote.test.ts` requires the translations of three price
refusal codes to exceed 20 characters, although startup accepts any nonblank
translation. `browser/acquisition.spec.ts` ages a checkout by 21 hours and
expects two recovery reminder emails; a customized reminder schedule needs its
timing fixture and expected reminder count adapted.
`browser/acquisition.spec.ts` also uses the demonstration saved-address formats,
account actions and pause defaults. The browser specs (`browser/*.spec.ts`,
including `editor-components.spec.ts`, `e4.spec.ts`, `journey.spec.ts` and
`subscription-journeys.spec.ts`) locate controls by their demonstration labels,
such as "Back to account"; rewording owned copy requires updating those
locators. After extraction, these are application tests. If you keep the callback-free policy, narrow action lists, omit
`retention.pausePreset` or rewrite copy, adapt or replace the affected fixtures
and assertions in your application. Startup validation defines the configuration
contract.

`test/installation.test.ts` checks that installation writes the schedule from
the owned configuration and accepts valid customized waves.
`test/checkout-recovery-stage.test.ts` checks subject selection for explicit
stages and the historical hour rule for legacy payloads.

Run typechecking, build, application tests and startup checks at the
verification step in the [starter upgrade order](README.md#starter-upgrade-order).
For npm-only applications, use the [package upgrade procedure](README.md#upgrade-the-packages-together).

## @openlup/platform

In 1.2.0, the additive stable commerce/server API includes
install/read helpers and a commerce/contracts schedule type. Existing
communications contracts gain an optional stage and widened reminder-hour inputs.
Native reminder producers read an installed `checkout_recovery_reminders`
schedule. Stage selects tone independently of hours. Absence preserves the
historical waves; old payloads render identically. Unknown stages follow each
handler's existing payload refusal. No new subpath or reminder planner is added.

Migration:

Apply `20261123140000_checkout_recovery_reminder_schedule.sql` through the native
migration runner before using the new helpers. Both producers retain their
signatures, security, search paths, owners and ACLs. The integer-only checkout
wrapper is unchanged. The new restricted SECURITY DEFINER validator pins
`search_path = pg_catalog, pg_temp`, qualifies its settings read, revokes PUBLIC
and conditionally revokes anon/authenticated and grants service_role EXECUTE.
Malformed JSON, extra/missing keys, blank revision, empty arrays, duplicate or
unknown stages, nonincreasing/nonpositive/noninteger hours or a missing final
`last` refuse with `checkout_recovery_reminder_schedule_invalid` before writes.
The maximum hour is 2147483647. The managed chain is unchanged.

Before (host-owned timing and legacy content):
```ts
import { createPostgresCheckoutRecoveryWaves } from '@openlup/platform/commerce/server';

declare const runtimeDb: Parameters<typeof createPostgresCheckoutRecoveryWaves>[0];
declare const emailVars: Record<string, unknown>;

const recovery = createPostgresCheckoutRecoveryWaves(runtimeDb, { profile: 'capture' });
const vars = { ...emailVars, reminderHours: 20 };
```

After (explicit install, then runtime read and stage-aware content):
```ts
import {
  createPostgresCheckoutRecoveryWaves,
  installCheckoutRecoveryReminderSchedule,
  readCheckoutRecoveryReminderSchedule,
} from '@openlup/platform/commerce/server';

declare const installationDb: Parameters<typeof installCheckoutRecoveryReminderSchedule>[0];
declare const runtimeDb: Parameters<typeof readCheckoutRecoveryReminderSchedule>[0];
declare const emailVars: Record<string, unknown>;

await installCheckoutRecoveryReminderSchedule(installationDb, { revision: 'store-1',
  abandonedCart: [{ stage: 'first', afterHours: 1 }, { stage: 'gentle', afterHours: 24 }, { stage: 'last', afterHours: 48 }],
  checkoutRecovery: [{ stage: 'first', afterHours: 1 }, { stage: 'last', afterHours: 48 }] });
const installed = await readCheckoutRecoveryReminderSchedule(runtimeDb);
const recovery = createPostgresCheckoutRecoveryWaves(runtimeDb,
  { profile: 'capture', checkoutSeconds: 72 * 3600 });
const vars = { ...emailVars, reminderHours: 48, stage: 'last' as const };
```

Reads never install. The TypeScript reader needs settings SELECT; enqueue uses
the restricted SQL validator without requiring settings SELECT. Custom runtime
roles must retain their existing producer and relation privileges.

Before (separate runtime producer grants):
```sql
GRANT EXECUTE ON FUNCTION public.commerce_enqueue_abandoned_cart_reminders(integer),
  public.commerce_enqueue_checkout_recovery_reminders(integer,jsonb,timestamptz) TO runtime_role;
```

After applying the migration, add exactly one grant:
```sql
GRANT EXECUTE ON FUNCTION public.commerce_checkout_recovery_reminder_schedule() TO runtime_role;
```

Qualified service-role bindings already receive it. Missing EXECUTE fails with
SQLSTATE `42501`, even with an absent setting; it never silently defaults.

Before (fixed SQL waves):
```sql
FOREACH wave IN ARRAY ARRAY[1,20] LOOP
```

After (strictly validated installed waves):
```sql
FOR entry IN SELECT value FROM jsonb_array_elements(
  public.commerce_checkout_recovery_reminder_schedule()->'checkoutRecovery') LOOP
```

Default dedup keys remain byte-identical. Custom waves derive keys by the same
hour spelling: `abandoned_<hours>h:<order-id>` and
`checkout_recovery:<hours>h:<order-id>`. Abandoned event types retain stage routes
1h/24h/72h. Legacy counter names count their corresponding stages. Final waves
retain the preceding-stage processed gate for abandoned carts and first-wave
confirmed-acceptance gate for checkout recovery; a lone `last` has no predecessor.
With an installed key, hours override legacy request offsets; absence retains
those offsets. Existing request-policy validation of legacy offsets (including
defaults) still applies. Checkout expiry, consent, payment activity and token deadlines
remain independent. Changing hours changes dedup identity and never rewrites
pending events or tokens; coordinate installation with in-flight reminders.

The source starter owns the schedule and installs only in its explicit install
step. Startup compares revision, stages and hours and refuses
`starter_installed_policy_drift` without writing. Existing starter applications
must add the owned input and install it deliberately.

1.2.0 adds optional `CheckoutReservationLifetimePolicy` to
`reservationPolicyFor` and `normalizedTtlMinutes` in the stable inventory subpath.
Positive integer bounds up to 5270400 minutes (ten years) must satisfy `minMinutes <= defaultMinutes <= maxMinutes`;
each call refuses invalid policy with `reservation_policy_invalid`. Omission
preserves the 1440–2160-minute clamp and 1440-minute fallback exactly.

Calculated expiry is persisted when a purchase reservation is created. Policy
changes do not rewrite stored expiry; matching replay retains the original
command expiry, reservation identity and current status. Native SQL still
requires finite future expiry for fresh holds, with its existing 30-minute
fallback for null. No SQL, starter composition or existing reservation changes.

Migration: no change is required. Before:
`reservationPolicyFor(input)` and `normalizedTtlMinutes(value)`. After:
`reservationPolicyFor(input, policy?)` and `normalizedTtlMinutes(value, policy?)`
with optional `CheckoutReservationLifetimePolicy`; existing calls keep the same
results. To configure, pass `{ minMinutes, maxMinutes, defaultMinutes }`, for
example `{ minMinutes: 1440, maxMinutes: 2160, defaultMinutes: 1440 }` for the
current behaviour.

1.2.0 adds `RenewalStockProtectionPolicy` and typed install/read
helpers to the stable inventory subpath, with the type also in inventory/contracts.
Native ATP reads the installed `inventory_renewal_protection` commerce setting.
Absence preserves 14 days with revision `default`; malformed JSON, extra/missing
keys, blank revision or noninteger/out-of-range days refuse with
`inventory_renewal_protection_policy_invalid`. Request horizons must match installed
days; `native_stock_read_options_unsupported` remains the mismatch refusal.

Migration:

Apply the native forward `20261123130000_inventory_renewal_protection_policy.sql`
through the migration runner before composing the new helpers. The forward retains
ATP's signature, language, volatility, invoker security, search path, owner and ACL.
It adds a restricted SECURITY DEFINER validator with the exact pinned
`search_path = pg_catalog, pg_temp`, a schema-qualified settings read, PUBLIC
revocation and conditional role revokes/service-role EXECUTE. ATP callers no
longer need SELECT on `commerce_settings`. The TypeScript policy reader still
needs that SELECT to return revision and days. No settings seed or subscription
lifecycle rewrite is performed. The managed adapter and SQL chain retain their
fixed 14-day contract.

Before (custom runtime role, alongside its relation privileges):

```sql
GRANT EXECUTE ON FUNCTION public.inventory_available_to_promise(text,text,timestamptz,boolean),
  public.inventory_channel_exposure_quantity(text,text) TO runtime_role;
```

Keep these and any existing new-purchase-reader EXECUTE grant. They alone now
fail with SQLSTATE `42501` on ATP, even with an absent policy.

After applying the policy migration and before resuming ATP calls, add exactly
one grant, substituting the host's role for `runtime_role`:

```sql
GRANT EXECUTE ON FUNCTION public.inventory_renewal_protection_days() TO runtime_role;
```

Qualified service-role bindings already receive this EXECUTE grant. Missing
permission never silently falls back to 14 days; every admitted role uses the
same installed stock policy.

Before (host):
```ts
import type { NewPurchaseStockReadPort } from '@openlup/platform/inventory';

declare const stock: { readPort: NewPurchaseStockReadPort };

const input = { skus: ['ITEM'], horizonDays: 14, excludeOrderId: null };
await stock.readPort.read(input);
```

After (explicit installation, then runtime composition):
```ts
import {
  installRenewalStockProtectionPolicy,
  readRenewalStockProtectionPolicy,
  type NewPurchaseStockReadPort,
} from '@openlup/platform/inventory';

declare const installationDb: Parameters<typeof installRenewalStockProtectionPolicy>[0];
declare const runtimeDb: Parameters<typeof readRenewalStockProtectionPolicy>[0];
declare const stock: { readPort: NewPurchaseStockReadPort };

// Install step only, on the host's write-capable connection:
await installRenewalStockProtectionPolicy(installationDb,
  { revision: 'store-1', renewalProtectionDays: 21 });
// Runtime only reads:
const policy = await readRenewalStockProtectionPolicy(runtimeDb);
await stock.readPort.read({ skus: ['ITEM'],
  horizonDays: policy.renewalProtectionDays, excludeOrderId: null });
```

Before (SQL horizon):
```sql
s.next_cycle_at <= p_as_of + interval '14 days'
```

After (installed horizon, validated once per ATP statement):
```sql
s.next_cycle_at <= p_as_of + make_interval(days => (SELECT days FROM policy))
-- policy materializes public.inventory_renewal_protection_days().
```

The source starter owns `inventory.renewalProtection` and installs it only through
its explicit installation step. Startup checks revision and days, refusing
`starter_installed_policy_drift` rather than writing. Existing applications must
add this owned input and install it deliberately. Unrelated raw editor settings
remain unchanged; the private package helper is not an adopter API.

- 1.2.0 adds optional `CustomerSavedAddressValidationPolicy.local` callbacks as
  an additive stable API change in the existing `@openlup/platform/shipping` subpath.
- Hosts may normalize and validate their local postal format and normalize or
  refuse their local phone format. Callbacks apply only to the selected local
  country (including aliases), must be effect-free and cannot perform I/O or
  authorization. A throw refuses the affected field with its existing policy
  message. Schema creation rejects missing or nonfunction local callbacks with
  `saved_address_policy_invalid`.
- Omitting `local` preserves the compatible five-digit postal and nine-digit /
  configured-prefix phone behavior. Platform length bounds, normalization order,
  aliases, foreign-country handling and message keys remain in force. Removing
  the compatible defaults is separate future work; no migration is required.

Migration: no change is required. Before: `CustomerSavedAddressValidationPolicy`
had `country`, `countryAliases`, `phonePrefix`, tax callbacks and `messages`.
After: it also accepts optional `local: { normalizePostalCode(value),
isValidPostalCode(value), normalizePhone(value) }`; omitting it keeps the
current behaviour.

### Added

- Let hosts pass authoritative, exact one-time offer allocations to the strict quote engine. Price component lines before promotions, shipping and tax while retaining independently read retail reference prices. Server quote snapshots carry versioned private offer-price provenance.
- Add opt-in explicit offer review to existing signed quote acceptance, including quotes without code, shipping or acquisition adjustments. A bound checkout offer can require that review.

Migration: no database migration. Existing callers keep their price, provenance and token behavior. Opt-in hosts must authorize the offer, resolve the full allocation on the server, sign and verify the same offer revision and checkout context, and re-resolve terms at acceptance. The server-only `catalog_facts_v3` variant is emitted for offers that opt in. Exhaustive TypeScript switches over `CatalogFactsProvenance` should handle the new variant even when the host leaves offer pricing disabled. Older authoritative quote snapshots continue to parse.

Follow the [fixed one-time offer guide](../how-to/build/quote-prices.md#price-a-fixed-one-time-offer) to wire the same pricing policy into preview, checkout and any re-quote, including recovery after token expiry.

1.2.0 adds stable `SubscriptionCommandAdmission` in the existing
subscriptions/contracts subpath and optional `admitSubscriptionCommand` on the
native command binding. Omitting it preserves existing behavior. Fresh preview
and apply evaluate effect-free owned policy after ownership, key locking and
receipt/fingerprint replay, before translation, pricing or writes. Thrown named
errors propagate with no durable refusal receipt. Native lifecycle, payment and
delivery fences remain unconditional. Completed matching commands replay after
policy narrows; payload conflicts still refuse before admission.

Admission reads payment facts in a fresh statement after acquiring the
subscription lock. Use READ COMMITTED (READ UNCOMMITTED has the same PostgreSQL
behavior); fresh admission refuses REPEATABLE READ and SERIALIZABLE with
`subscription_command_admission_isolation_unsupported` before the callback or
writes. Completed receipts still replay before this check.

The source starter owns account action lists and pause choices in
`owned/renewal.config.ts`. The account pause form preselects the preset default
(`2_weeks` in the demo) and the cancellation save offer keeps its own
`retention.pausePreset` (`1_month`), so starter defaults are unchanged.

Migration: no SQL, schema or installed-policy changes. This additive stable API
shipped in the 1.2.0 minor set.
Opt in through host composition; never place the callback in a browser payload
or perform I/O from it. When upgrading starter application files, add
`subscriptionCare.actions` and `pausePresets` to the owned input. Invalid lists
or defaults refuse startup. A removed choice affects fresh work only.

- In 1.2.0, native purchase activation accepts optional `editWindowHours`
  (integer 1–720), validated with
  `subscription_activation_edit_window_invalid` before database access. Omission
  retains the installed 72-hour default. The value freezes on the created
  subscription; configuration changes and completed replay preserve existing rows.
- Existing native activation/repair signatures and ACLs remain unchanged. New
  separately named invoker SQL functions contain their predecessor bodies with
  the new input and pinned `public, pg_catalog` search paths. The forward never
  redefines or changes privileges on the predecessors. New functions revoke
  PUBLIC/anon/authenticated and grant EXECUTE to service_role where present.
  Managed checkout activation remains a separate unchanged boundary.

Migration: Apply the complete packaged native chain including
`20261123120000_subscription_edit_window_activation.sql` before supplying the new
input. Opting in requires EXECUTE on both new functions (granted to service_role
where present; owner-run self-host installations have it as owner). Old callers
that omit it call the unchanged predecessor with its existing privileges.
The starter owns
`subscriptionCreation.editWindowHours` (default 72) and validates it at startup
with `starter_subscription_creation_invalid`; all initial activation routes pass
it, including 72, and therefore opt in.

## API changes

### `packages/platform/api/account-support.api.md`

Added declarations:

```ts nocheck
// API report diff: not compiled.
export interface CheckoutRecoveryReminderSchedule {
export type { CheckoutRecoveryReminderSchedule } from "./checkoutRecoveryReminders.js";
```

Changed declarations:

```ts nocheck
// API report diff: not compiled.
export type CheckoutOfferResolution = {
export interface CheckoutOfferPolicyPort<Intent, Quote> {
```

### `packages/platform/api/catalog.api.md`

Added declarations:

```ts nocheck
// API report diff: not compiled.
export { CATALOG_FACTS_PROVENANCE_VERSION, CATALOG_FACTS_POLICY_PROVENANCE_VERSION, CATALOG_FACTS_OFFER_PROVENANCE_VERSION } from "./provenance.js";
export declare const CATALOG_FACTS_OFFER_PROVENANCE_VERSION: "catalog_facts_v3";
export type { OneTimeOfferPricing } from "./oneTimeOfferPricing.js";
export interface OneTimeOfferPricing {
export declare function resolveOneTimeOfferPricing(input: OneTimeOfferPricing | undefined, request: CreateQuoteRequest, currency: string, useStrictCatalog: boolean): {
export declare function invalidOfferPricing(): CommerceQuoteError;
```

Removed declarations:

```ts nocheck
// API report diff: not compiled.
export { CATALOG_FACTS_PROVENANCE_VERSION, CATALOG_FACTS_POLICY_PROVENANCE_VERSION } from "./provenance.js";
```

Changed declarations:

```ts nocheck
// API report diff: not compiled.
export declare function createCatalogFactsProvenance(input: {
export declare function catalogFactsForQuoteLine(enabled: boolean, item: CommerceQuoteCatalogItem, resolved: ResolvedPriceObservation, base: ResolvedPriceObservation, mode: "one_time" | "subscription", atTime: string, currency: string, resolvedUnitAmountMinor: number, resolvedLineAmountMinor: number, baseUnitAmountMinor: number, policy?: PolicyDerivedSubscriptionFacts, offerPriceReference?: string): CatalogFactsProvenance | undefined;
export declare const catalogFactsProvenanceSchema: z.ZodUnion<readonly [z.ZodObject<{
export type CatalogFactsProvenance = CatalogFactsFields & ({
export interface CreateQuoteOptions {
export declare function createCommerceQuoteSchemas<Context extends z.ZodType>(input: {
export interface CustomerSavedAddressValidationPolicy {
```

### `packages/platform/api/commerce-contracts.api.md`

Added declarations:

```ts nocheck
// API report diff: not compiled.
export interface CheckoutRecoveryReminderSchedule {
export type { CheckoutRecoveryReminderSchedule } from "./checkoutRecoveryReminders.js";
```

Changed declarations:

```ts nocheck
// API report diff: not compiled.
export type CheckoutOfferResolution = {
export interface CheckoutOfferPolicyPort<Intent, Quote> {
```

### `packages/platform/api/commerce-native-checkout.api.md`

Added declarations:

```ts nocheck
// API report diff: not compiled.
export { CATALOG_FACTS_PROVENANCE_VERSION, CATALOG_FACTS_POLICY_PROVENANCE_VERSION, CATALOG_FACTS_OFFER_PROVENANCE_VERSION } from "./provenance.js";
export declare const CATALOG_FACTS_OFFER_PROVENANCE_VERSION: "catalog_facts_v3";
export type { OneTimeOfferPricing } from "./oneTimeOfferPricing.js";
export interface OneTimeOfferPricing {
export declare function resolveOneTimeOfferPricing(input: OneTimeOfferPricing | undefined, request: CreateQuoteRequest, currency: string, useStrictCatalog: boolean): {
export declare function invalidOfferPricing(): CommerceQuoteError;
```

Removed declarations:

```ts nocheck
// API report diff: not compiled.
export { CATALOG_FACTS_PROVENANCE_VERSION, CATALOG_FACTS_POLICY_PROVENANCE_VERSION } from "./provenance.js";
```

Changed declarations:

```ts nocheck
// API report diff: not compiled.
export declare function createCatalogFactsProvenance(input: {
export declare function catalogFactsForQuoteLine(enabled: boolean, item: CommerceQuoteCatalogItem, resolved: ResolvedPriceObservation, base: ResolvedPriceObservation, mode: "one_time" | "subscription", atTime: string, currency: string, resolvedUnitAmountMinor: number, resolvedLineAmountMinor: number, baseUnitAmountMinor: number, policy?: PolicyDerivedSubscriptionFacts, offerPriceReference?: string): CatalogFactsProvenance | undefined;
export declare const catalogFactsProvenanceSchema: z.ZodUnion<readonly [z.ZodObject<{
export type CatalogFactsProvenance = CatalogFactsFields & ({
export interface CreateQuoteOptions {
export declare function createCommerceQuoteSchemas<Context extends z.ZodType>(input: {
export interface CustomerSavedAddressValidationPolicy {
```

### `packages/platform/api/commerce-server-postgres.api.md`

Added declarations:

```ts nocheck
// API report diff: not compiled.
export { CATALOG_FACTS_PROVENANCE_VERSION, CATALOG_FACTS_POLICY_PROVENANCE_VERSION, CATALOG_FACTS_OFFER_PROVENANCE_VERSION } from "./provenance.js";
export declare const CATALOG_FACTS_OFFER_PROVENANCE_VERSION: "catalog_facts_v3";
export type { OneTimeOfferPricing } from "./oneTimeOfferPricing.js";
export interface OneTimeOfferPricing {
export declare function resolveOneTimeOfferPricing(input: OneTimeOfferPricing | undefined, request: CreateQuoteRequest, currency: string, useStrictCatalog: boolean): {
export declare function invalidOfferPricing(): CommerceQuoteError;
```

Removed declarations:

```ts nocheck
// API report diff: not compiled.
export { CATALOG_FACTS_PROVENANCE_VERSION, CATALOG_FACTS_POLICY_PROVENANCE_VERSION } from "./provenance.js";
```

Changed declarations:

```ts nocheck
// API report diff: not compiled.
export declare function createCatalogFactsProvenance(input: {
export declare function catalogFactsForQuoteLine(enabled: boolean, item: CommerceQuoteCatalogItem, resolved: ResolvedPriceObservation, base: ResolvedPriceObservation, mode: "one_time" | "subscription", atTime: string, currency: string, resolvedUnitAmountMinor: number, resolvedLineAmountMinor: number, baseUnitAmountMinor: number, policy?: PolicyDerivedSubscriptionFacts, offerPriceReference?: string): CatalogFactsProvenance | undefined;
export declare const catalogFactsProvenanceSchema: z.ZodUnion<readonly [z.ZodObject<{
export type CatalogFactsProvenance = CatalogFactsFields & ({
export interface CreateQuoteOptions {
export declare function createCommerceQuoteSchemas<Context extends z.ZodType>(input: {
export interface CustomerSavedAddressValidationPolicy {
```

### `packages/platform/api/commerce-server.api.md`

Added declarations:

```ts nocheck
// API report diff: not compiled.
export interface CheckoutRecoveryReminderSchedule {
export type { CheckoutRecoveryReminderSchedule } from "./checkoutRecoveryReminders.js";
interface Executor {
export declare function installCheckoutRecoveryReminderSchedule(db: Executor, schedule: CheckoutRecoveryReminderSchedule): Promise<void>;
export declare function readCheckoutRecoveryReminderSchedule(db: Executor): Promise<CheckoutRecoveryReminderSchedule>;
export { installCheckoutRecoveryReminderSchedule, readCheckoutRecoveryReminderSchedule } from "./checkoutRecoveryReminderSchedule.js";
export { CATALOG_FACTS_PROVENANCE_VERSION, CATALOG_FACTS_POLICY_PROVENANCE_VERSION, CATALOG_FACTS_OFFER_PROVENANCE_VERSION } from "./provenance.js";
export declare const CATALOG_FACTS_OFFER_PROVENANCE_VERSION: "catalog_facts_v3";
export type { OneTimeOfferPricing } from "./oneTimeOfferPricing.js";
export interface OneTimeOfferPricing {
export declare function resolveOneTimeOfferPricing(input: OneTimeOfferPricing | undefined, request: CreateQuoteRequest, currency: string, useStrictCatalog: boolean): {
export declare function invalidOfferPricing(): CommerceQuoteError;
```

Removed declarations:

```ts nocheck
// API report diff: not compiled.
export { CATALOG_FACTS_PROVENANCE_VERSION, CATALOG_FACTS_POLICY_PROVENANCE_VERSION } from "./provenance.js";
```

Changed declarations:

```ts nocheck
// API report diff: not compiled.
export type CheckoutOfferResolution = {
export interface CheckoutOfferPolicyPort<Intent, Quote> {
export interface CheckoutRecoveryEmailInput<Locale extends string = string> {
export type CheckoutOfferBinding<Intent, Quote> = {
export declare function createCommerceCheckoutHandler<Deps extends CheckoutHandlerDependencies, Intent extends ConfiguratorIntent, Provisioned extends {
export type CheckoutQuoteGuardResult<Snapshot, Response> = {
export declare function createCatalogFactsProvenance(input: {
export declare function catalogFactsForQuoteLine(enabled: boolean, item: CommerceQuoteCatalogItem, resolved: ResolvedPriceObservation, base: ResolvedPriceObservation, mode: "one_time" | "subscription", atTime: string, currency: string, resolvedUnitAmountMinor: number, resolvedLineAmountMinor: number, baseUnitAmountMinor: number, policy?: PolicyDerivedSubscriptionFacts, offerPriceReference?: string): CatalogFactsProvenance | undefined;
export declare const catalogFactsProvenanceSchema: z.ZodUnion<readonly [z.ZodObject<{
export type CatalogFactsProvenance = CatalogFactsFields & ({
export interface CreateQuoteOptions {
export declare function createCommerceQuoteSchemas<Context extends z.ZodType>(input: {
export interface CustomerSavedAddressValidationPolicy {
```

### `packages/platform/api/commerce.api.md`

Added declarations:

```ts nocheck
// API report diff: not compiled.
export interface CheckoutRecoveryReminderSchedule {
export type { CheckoutRecoveryReminderSchedule } from "./checkoutRecoveryReminders.js";
```

Changed declarations:

```ts nocheck
// API report diff: not compiled.
export type CheckoutOfferResolution = {
export interface CheckoutOfferPolicyPort<Intent, Quote> {
export interface CheckoutRecoveryEmailInput<Locale extends string = string> {
```

### `packages/platform/api/communications-contracts.api.md`

Changed declarations:

```ts nocheck
// API report diff: not compiled.
export interface AbandonedCartEmailVars {
export interface CheckoutRecoveryEmailVars {
```

### `packages/platform/api/inventory-contracts.api.md`

Added declarations:

```ts nocheck
// API report diff: not compiled.
export type { CheckoutReservationLifetimePolicy, ReservationPolicyInput, ReservationPolicy, AutomaticRenewalReservationResult } from "./reservation.js";
export type { RenewalStockProtectionPolicy } from "./renewalStockProtection.js";
export interface RenewalStockProtectionPolicy {
export interface CheckoutReservationLifetimePolicy {
```

Removed declarations:

```ts nocheck
// API report diff: not compiled.
export type { ReservationPolicyInput, ReservationPolicy, AutomaticRenewalReservationResult } from "./reservation.js";
```

### `packages/platform/api/inventory.api.md`

Added declarations:

```ts nocheck
// API report diff: not compiled.
export type { CheckoutReservationLifetimePolicy, ReservationPolicyInput, ReservationPolicy, AutomaticRenewalReservationResult } from "./reservation.js";
export type { RenewalStockProtectionPolicy } from "./renewalStockProtection.js";
export interface RenewalStockProtectionPolicy {
export interface CheckoutReservationLifetimePolicy {
export type { CheckoutReservationLifetimePolicy } from "./contracts/reservation.js";
export type { RenewalStockProtectionPolicy } from "./contracts/renewalStockProtection.js";
export { installRenewalStockProtectionPolicy, readRenewalStockProtectionPolicy } from "./renewalStockProtection.js";
interface Executor {
export declare function installRenewalStockProtectionPolicy(db: Executor, policy: RenewalStockProtectionPolicy): Promise<void>;
export declare function readRenewalStockProtectionPolicy(db: Executor): Promise<RenewalStockProtectionPolicy>;
```

Removed declarations:

```ts nocheck
// API report diff: not compiled.
export type { ReservationPolicyInput, ReservationPolicy, AutomaticRenewalReservationResult } from "./reservation.js";
```

Changed declarations:

```ts nocheck
// API report diff: not compiled.
export declare function createPostgresStockAvailability(executor: StockQueryExecutor, options: {
export declare function reservationPolicyFor(input: ReservationPolicyInput, policy?: CheckoutReservationLifetimePolicy): ReservationPolicy;
export declare function normalizedTtlMinutes(value: number | null | undefined, policy?: CheckoutReservationLifetimePolicy): number;
```

### `packages/platform/api/marketing-server.api.md`

Changed declarations:

```ts nocheck
// API report diff: not compiled.
export interface AbandonedCartEmailVars {
export interface CheckoutRecoveryEmailVars {
```

### `packages/platform/api/pricing-browser.api.md`

Added declarations:

```ts nocheck
// API report diff: not compiled.
export declare const CATALOG_FACTS_OFFER_PROVENANCE_VERSION: "catalog_facts_v3";
```

Changed declarations:

```ts nocheck
// API report diff: not compiled.
export type CatalogFactsProvenance = CatalogFactsFields & ({
```

### `packages/platform/api/pricing-contracts.api.md`

Added declarations:

```ts nocheck
// API report diff: not compiled.
export { CATALOG_FACTS_PROVENANCE_VERSION, CATALOG_FACTS_POLICY_PROVENANCE_VERSION, CATALOG_FACTS_OFFER_PROVENANCE_VERSION } from "./provenance.js";
export declare const CATALOG_FACTS_OFFER_PROVENANCE_VERSION: "catalog_facts_v3";
```

Removed declarations:

```ts nocheck
// API report diff: not compiled.
export { CATALOG_FACTS_PROVENANCE_VERSION, CATALOG_FACTS_POLICY_PROVENANCE_VERSION } from "./provenance.js";
```

Changed declarations:

```ts nocheck
// API report diff: not compiled.
export type CatalogFactsProvenance = CatalogFactsFields & ({
```

### `packages/platform/api/pricing.api.md`

Added declarations:

```ts nocheck
// API report diff: not compiled.
export { CATALOG_FACTS_PROVENANCE_VERSION, CATALOG_FACTS_POLICY_PROVENANCE_VERSION, CATALOG_FACTS_OFFER_PROVENANCE_VERSION } from "./provenance.js";
export declare const CATALOG_FACTS_OFFER_PROVENANCE_VERSION: "catalog_facts_v3";
export type { OneTimeOfferPricing } from "./oneTimeOfferPricing.js";
export interface OneTimeOfferPricing {
export declare function resolveOneTimeOfferPricing(input: OneTimeOfferPricing | undefined, request: CreateQuoteRequest, currency: string, useStrictCatalog: boolean): {
export declare function invalidOfferPricing(): CommerceQuoteError;
```

Removed declarations:

```ts nocheck
// API report diff: not compiled.
export { CATALOG_FACTS_PROVENANCE_VERSION, CATALOG_FACTS_POLICY_PROVENANCE_VERSION } from "./provenance.js";
```

Changed declarations:

```ts nocheck
// API report diff: not compiled.
export declare function createCatalogFactsProvenance(input: {
export declare function catalogFactsForQuoteLine(enabled: boolean, item: CommerceQuoteCatalogItem, resolved: ResolvedPriceObservation, base: ResolvedPriceObservation, mode: "one_time" | "subscription", atTime: string, currency: string, resolvedUnitAmountMinor: number, resolvedLineAmountMinor: number, baseUnitAmountMinor: number, policy?: PolicyDerivedSubscriptionFacts, offerPriceReference?: string): CatalogFactsProvenance | undefined;
export declare const catalogFactsProvenanceSchema: z.ZodUnion<readonly [z.ZodObject<{
export type CatalogFactsProvenance = CatalogFactsFields & ({
export interface CreateQuoteOptions {
export declare function createCommerceQuoteSchemas<Context extends z.ZodType>(input: {
export interface CustomerSavedAddressValidationPolicy {
```

### `packages/platform/api/promotions.api.md`

Added declarations:

```ts nocheck
// API report diff: not compiled.
export { CATALOG_FACTS_PROVENANCE_VERSION, CATALOG_FACTS_POLICY_PROVENANCE_VERSION, CATALOG_FACTS_OFFER_PROVENANCE_VERSION } from "./provenance.js";
export declare const CATALOG_FACTS_OFFER_PROVENANCE_VERSION: "catalog_facts_v3";
export type { OneTimeOfferPricing } from "./oneTimeOfferPricing.js";
export interface OneTimeOfferPricing {
export declare function resolveOneTimeOfferPricing(input: OneTimeOfferPricing | undefined, request: CreateQuoteRequest, currency: string, useStrictCatalog: boolean): {
export declare function invalidOfferPricing(): CommerceQuoteError;
```

Removed declarations:

```ts nocheck
// API report diff: not compiled.
export { CATALOG_FACTS_PROVENANCE_VERSION, CATALOG_FACTS_POLICY_PROVENANCE_VERSION } from "./provenance.js";
```

Changed declarations:

```ts nocheck
// API report diff: not compiled.
export declare function createCatalogFactsProvenance(input: {
export declare function catalogFactsForQuoteLine(enabled: boolean, item: CommerceQuoteCatalogItem, resolved: ResolvedPriceObservation, base: ResolvedPriceObservation, mode: "one_time" | "subscription", atTime: string, currency: string, resolvedUnitAmountMinor: number, resolvedLineAmountMinor: number, baseUnitAmountMinor: number, policy?: PolicyDerivedSubscriptionFacts, offerPriceReference?: string): CatalogFactsProvenance | undefined;
export declare const catalogFactsProvenanceSchema: z.ZodUnion<readonly [z.ZodObject<{
export type CatalogFactsProvenance = CatalogFactsFields & ({
export interface CreateQuoteOptions {
export declare function createCommerceQuoteSchemas<Context extends z.ZodType>(input: {
export declare function createPromotionQuoteAcceptance<Request extends {
export interface CustomerSavedAddressValidationPolicy {
```

### `packages/platform/api/shipping.api.md`

Changed declarations:

```ts nocheck
// API report diff: not compiled.
export interface CustomerSavedAddressValidationPolicy {
```

### `packages/platform/api/subscriptions-contracts.api.md`

Added declarations:

```ts nocheck
// API report diff: not compiled.
export type SubscriptionCommandAdmission = (facts: {
export type { SubscriptionLifecycleTerms, SubscriptionCancelSurvey, SubscriptionSaveOffer, SubscriptionCommandContext, SubscriptionCommand, SubscriptionCommandAdmission, SubscriptionBundleLine, SubscriptionCommandReceipt, SubscriptionCommandRefusal, SubscriptionUnsupportedCode, SubscriptionUnsupported, SubscriptionCapabilities, SubscriptionCommandPort, SubscriptionActivationPort } from "./commands.js";
```

Removed declarations:

```ts nocheck
// API report diff: not compiled.
export type { SubscriptionLifecycleTerms, SubscriptionCancelSurvey, SubscriptionSaveOffer, SubscriptionCommandContext, SubscriptionCommand, SubscriptionBundleLine, SubscriptionCommandReceipt, SubscriptionCommandRefusal, SubscriptionUnsupportedCode, SubscriptionUnsupported, SubscriptionCapabilities, SubscriptionCommandPort, SubscriptionActivationPort } from "./commands.js";
```

### `packages/platform/api/subscriptions.api.md`

Added declarations:

```ts nocheck
// API report diff: not compiled.
export type SubscriptionCommandAdmission = (facts: {
```

Changed declarations:

```ts nocheck
// API report diff: not compiled.
export declare function activateNativePurchaseWithRenewal(executor: SubscriptionQueryExecutor, input: {
export interface NativeSubscriptionCommandBinding {
export declare function createPostgresSubscriptionCommandStore(binding: Pick<NativeSubscriptionCommandBinding, "withTransaction" | "lifecycleTerms" | "retentionReasonCodes" | "admitSubscriptionCommand">): {
```
