# Upgrading

## 2.x → 3.0.0

3.0.0 makes inbound verification generic. It removes the vendor-specific
verifier modules and the name-to-module convention, and adds a configuration
layer that expresses each removed scheme, and many others, in one small module
in your application. There are two breaking changes; nothing else changes shape.
No migration and no dependency change is needed.

If you are upgrading from an earlier 2.x release, also read the section for each
release you skip.

### Breaking: every inbound declaration needs `provider`

2.x resolved a missing `provider` to `AshHooks.Provider.<CamelizedName>`, so
`inbound :comply_cube` found `AshHooks.Provider.ComplyCube`. That convention is
gone. A declaration without `provider` fails to compile with a message naming
the fix:

```elixir
webhooks do
  inbound :comply_cube do
    provider MyApp.Webhooks.ComplyCube
    secret {:app_env, [:my_app, :complycube_secret]}
  end
end
```

**Keep each inbound name exactly as it was.** The name is stored in the ledger's
`provider` column and is part of every deduplication identity, so renaming a
source would let already-recorded deliveries be processed again.

### Breaking: the vendor verifier modules are removed

These modules no longer exist: `AshHooks.Provider.ComplyCube` (with
`ComplyCube.Event`), `AshHooks.Provider.HubSpotV3` (with `HubSpotV3.Event` and
`decode_request_uri/1`), `AshHooks.Provider.Twilio`, `AshHooks.Provider.Stripe`,
`AshHooks.Provider.Shopify`, `AshHooks.Provider.WooCommerce`,
`AshHooks.Provider.Shippo`, `AshHooks.Provider.EasyPost`,
`AshHooks.Provider.Magento2`, `AshHooks.Provider.BigCommerce`,
`AshHooks.Provider.Ecwid`, `AshHooks.Provider.Squarespace`, and
`AshHooks.Provider.Wix`.

Replace each with a provider module in your application. Most need only
configuration:

```elixir
defmodule MyApp.Webhooks.Shopify do
  use AshHooks.Provider,
    verify: [
      algorithm: :hmac_sha256,
      signature: {:header, "x-shopify-hmac-sha256"},
      encoding: :base64
    ]
end
```

The table gives the configuration that reproduces each removed module's
signature check. These rows are migration examples, not maintained integrations.
Each sender's documentation is authoritative, and the guide's recipes link to it.
The [Verify any sender](documentation/tutorials/verify-any-sender.md) guide has
the complete modules for the rows marked *recipe*, which need a host function.

| Removed module | Replacement `verify:` options |
| --- | --- |
| `ComplyCube` | `algorithm: :hmac_sha256, signature: {:header, "complycube-signature"}, encoding: :hex` |
| `HubSpotV3` | `algorithm: :hmac_sha256, signature: {:header, "x-hubspot-signature-v3"}, encoding: :base64, timestamp: {:header, "x-hubspot-request-timestamp"}, timestamp_unit: :milliseconds`, plus a `signed_input` function for its URI decoding (*recipe*: [Method, URL, body, and timestamp](documentation/tutorials/verify-any-sender.md#method-url-body-and-timestamp)) |
| `Twilio` | `algorithm: :hmac_sha1, signature: {:header, "x-twilio-signature"}, encoding: :base64`, plus a `signed_input` function for its sorted form fields and `bodySHA256` (*recipe*: [Sorted form fields](documentation/tutorials/verify-any-sender.md#sorted-form-fields)) |
| `Stripe` | `algorithm: :hmac_sha256, signature: {:structured_header, "stripe-signature", signature_key: "v1"}, timestamp: {:signature_field, "t"}, signed_input: [:timestamp, ".", :body]` |
| `Shopify` | `algorithm: :hmac_sha256, signature: {:header, "x-shopify-hmac-sha256"}, encoding: :base64` |
| `WooCommerce` | `algorithm: :hmac_sha256, signature: {:header, "x-wc-webhook-signature"}, encoding: :base64` |
| `Shippo` | as `Stripe`, with `{:structured_header, "shippo-auth-signature", signature_key: "v1"}` |
| `EasyPost` (v1) | `algorithm: :hmac_sha256, signature: {:header, "x-hmac-signature", prefix: "hmac-sha256-hex="}, encoding: :hex`; return the NFKD-normalized secret from your secret source |
| `EasyPost` (v2) | `algorithm: :hmac_sha256, signature: {:header, "x-hmac-signature-v2", prefix: "hmac-sha256-hex="}, encoding: :hex_any, signed_input: [{:header, "x-timestamp"}, :method, :path, :body], tolerance_seconds: 60`, plus a `timestamp` function for RFC 2822 (*recipe*: [A timestamp in another format](documentation/tutorials/verify-any-sender.md#a-timestamp-in-another-format)); choose v1 or v2 per request as in [Two schemes on one route](documentation/tutorials/verify-any-sender.md#two-schemes-on-one-route) |
| `Magento2` | `algorithm: :rsa_pkcs1_sha256, signature: {:header, "x-adobe-commerce-webhook-signature"}, encoding: :base64, signed_input: [{:base64, :body}]`; the secret source returns the public PEM key |
| `BigCommerce` | `algorithm: :hmac_sha256, signature: {:structured_header, "webhook-signature", signature_key: "v1", pair_separator: " ", key_value_separator: ","}, encoding: :base64, timestamp: {:header, "webhook-timestamp"}, signed_input: [{:header, "webhook-id"}, ".", :timestamp, ".", :body]`; the secret source returns the raw client secret |
| `Ecwid` | `algorithm: :hmac_sha256, signature: {:header, "x-ecwid-webhook-signature"}, encoding: :base64`, plus a `signed_input` function and `event_identity/1` (*recipe*: [A signature over selected payload fields](documentation/tutorials/verify-any-sender.md#a-signature-over-selected-payload-fields)) |
| `Squarespace` | `algorithm: :hmac_sha256, signature: {:header, "squarespace-signature"}, encoding: :hex, key_encoding: :hex` |
| `Wix` | `algorithm: :rsa_pkcs1_sha256, signature: :jws_body`; the secret source returns the public PEM key |

Configured providers read their signature from the request headers. In your
controller, pass `headers: conn.req_headers` to `AshHooks.Ingress.ingest/4`;
`ctx.signature` is no longer needed for them. Keep
passing `method` and the public `request_uri` for schemes that sign them.

Differences from the removed modules, all deliberate:

- A configured provider classifies every request as `:webhook` and returns
  `AshHooks.Provider.Event`. `ComplyCube` and `HubSpotV3` mapped event names to
  atoms and returned their own event structs. If your handlers or stored
  `external_event_type` values depend on those atoms, override
  `parse_event_type/1` with the same mapping (the 2.3.0 source lists both
  tables:
  [ComplyCube](https://github.com/baselabs/ash_hooks/blob/v2.3.0/lib/ash_hooks/provider/comply_cube.ex),
  [HubSpotV3](https://github.com/baselabs/ash_hooks/blob/v2.3.0/lib/ash_hooks/provider/hub_spot_v3.ex))
  and keep the atom names.
- `HubSpotV3` and `Ecwid` implemented `event_identity/1`. If your ledger already
  holds rows for those sources, implement the same identity in your provider so
  redeliveries keep matching existing rows. For Ecwid that is the signed
  `eventId` (shown in the recipe). For HubSpot it was a SHA-256 of the batch that
  ignored each event's `attemptNumber`, sorted object keys and the outer event
  order, and kept nested list order; copy the
  [2.3.0 implementation](https://github.com/baselabs/ash_hooks/blob/v2.3.0/lib/ash_hooks/provider/hub_spot_v3.ex)
  if you depend on it.
- `Twilio` decoded JSON or form bodies itself. Declare `body_format :form` on a
  form route, or implement `decode_payload/1`.
- Signature prefixes are matched without regard to ASCII case.
- EasyPost v2 accepted 60 seconds of age and 30 seconds of future skew; a
  configured tolerance is symmetric.
- `Wix` deduplicated on the SHA-256 of the raw body. A configured `:jws_body`
  provider deduplicates on the SHA-256 of the verified payload, so a redelivery
  of an event recorded under 2.x gets a new identity and runs again. If your
  ledger holds Wix rows, move them with
  `AshHooks.Ingress.plan_legacy_identity_adoption/3` and
  `adopt_legacy_identity/3`, or keep the raw-body identity: write the provider
  with plain `use AshHooks.Provider`, call `Scheme.verify/4` from
  `verify_signature/3` and `Scheme.decode_payload/2` from `decode_payload/1`, and
  return `:body` from `signature_source/0`.
- `Wix` accepted padded base64url segments. JWS verification accepts only
  unpadded segments, as RFC 7515 requires.

### What stays the same

- `AshHooks.Provider`, every callback, and `default_verify_signature/4`.
  `signature_source/0` gains a third value, `:request`, for providers that read
  their own signature from the headers; `:header` (the default) and `:body` keep
  their meaning.
- `AshHooks.Provider.Hmac` keeps its options and behavior, and its `:algorithm`
  option now also accepts `:sha384` and `:sha512`. New code can use
  `use AshHooks.Provider, verify: [...]`, which covers the same ground and more.
- `AshHooks.Provider.Event` and `AshHooks.Provider.Mock`.
- Form bodies, batch payloads, tenant-aware `paused` and `previous_secret`,
  retry-status selection, certificate pins, host delivery headers, outbound
  signing (`AshHooks.Signing`), and every resource, column, action, and
  telemetry event.

### New

- Pass `headers: conn.req_headers` (the ordered list) instead of building a map.
  Providers then receive every header line in `ctx.header_list`, and repeated
  lines are joined with `", "` in `ctx.headers`. A map you pass is still delivered
  unchanged, but it has already lost repeated lines, so a provider that reads a
  header that can repeat should read `ctx.header_list`. If you passed a list in
  2.x, outside the documented map type, providers now receive a map in
  `ctx.headers`.
- A configured `:jws_body` provider deduplicates on its verified payload
  (`Scheme.payload_identity/1`).
- `use AshHooks.Provider, verify: [...]` generates a provider from
  configuration. `AshHooks.Provider.Scheme` documents every option and exposes
  `Scheme.verify/4` for direct calls.
- `AshHooks.Provider.Signature` is now public: `hmac/4`, `rsa/4`, `ecdsa/4`,
  `ed25519/4`, `jws/3`, `compare/2`, `header/2`, and `check_timestamp/3`.

## 2.2.1 → 2.3.0

**Nothing is required for existing adopters.** No migration, dependency, or
existing default changes. The new behavior is opt-in, apart from fixing the
documented tenant-aware `paused` and `previous_secret` callbacks: one-argument
callbacks receive the resolved tenant on multitenant ledgers. Calls without a
tenant behave as before. Zero-argument, `{module, function, args}` and app-env
sources keep working. `previous_secret` app-env sources accept the documented
binary value; the `{:ok, key}` environment shape also works.

- Opt into URL-encoded ingress with `body_format :form` on an inbound declaration
  or a provider's optional `body_format/0`. The raw bytes still reach signature
  verification unchanged. JSON remains the default. Providers can decode a signed
  body envelope with `decode_payload/1` and declare it with `signature_source/0`.
- 2.3.0 added vendor verifier modules. 3.0.0 removes them; configure your own
  provider instead, as described in the 3.0.0 section above.
- Host-owned emitters can use `AshHooks.Provider.Hmac.verify_signature/4` with
  trusted options for header, algorithm, hex or base64, timestamp tolerance,
  canonical input, and overlap keys.
- Set `retryable_statuses` on the worker or direct-run config to replace the
  ordinary HTTP retry set. Omit it to keep the default. 2xx, redirects, and 410
  retain their existing rules; configured retry responses honor `Retry-After`.
- Add `delivery_headers: {module, function}` on the worker/direct-run config.
  It receives `(delivery, endpoint, tenant)` and returns binary header pairs.
  Direct configuration also accepts a map/list or function. Package-owned signing,
  content-type, and framing headers cannot be overridden, regardless of case.
- Optional certificate pins use `certificate_pin: {module, function}` on a worker
  or direct run, resolving `(endpoint, tenant)` to a pin or `nil`. A host-wide
  pin can also live in `http_opts[:certificate_pin]`. Supported pins are exact
  DER leaf certificate, SHA-256 of that DER, or SHA-256 of DER SubjectPublicKeyInfo.
  Pins require HTTPS and the bounded adapter; normal TLS and SSRF checks stay on.
  Mismatch and configuration failures are non-retryable and send no body bytes.

See [README.md](README.md) for examples.

## 2.2.0 → 2.2.1

- **`auto_disable` declarants gain the `disable_warned_at` column.** The
  warning-first fix stores the standing "a warning sweep has fired" fact
  on the endpoint; declaring `auto_disable` now injects the marker column
  and its machine action — add the column to the endpoint table's
  migration when you upgrade. A disable lands one sweep after the first
  qualifying warning, which is the behavior 2.2.0's moduledoc already
  described.

## 2.1.x → 2.2.0

New OPTIONAL surface — nothing changes for an install that adopts none of
it: no existing column, action, event, or default behavior moves.

- **Attempt history (opt-in).** To record every delivery attempt (time,
  outcome, classified reason, HTTP status, latency, the signing key
  reference), create a resource with the new `AshHooks.OutboundAttempt`
  extension, migrate its table (the tutorial carries the DDL, including the
  `unique_attempt` index on `[:delivery_pk, :attempt]`), and pass
  `attempts: MyApp.OutboundAttempt` to `use AshHooks.Worker` (or the direct
  `AshHooks.Delivery.run/2` config). The runtime writes rows through the
  injected `:record` action; cover it with an action-specific policy like
  every other injected write action.
- **Per-endpoint response capture (opt-in).** Declaring
  `response_capture_attributes :on` on the endpoint resource injects four
  columns (`response_capture`, `response_capture_max_bytes`,
  `response_capture_retention_seconds`, `response_header_allowlist`) —
  migrate them when you declare it. Capture remains per-row opt-in
  (`response_capture: true`); captured bytes are bounded, redacted, and
  header capture is allowlist-only.
- **Delivery-log queries.** `AshHooks.Delivery.list/2` and
  `AshHooks.OutboundAttempt.list/2` filter by endpoint, status/outcome,
  event type, and time range with keyset pagination; the delivery resource
  needs `timestamps()` and an `:id` attribute for them.
- **Test-send flagging (opt-in).** Declaring `test_tracking :on` under
  `outbound_delivery` injects the `test` boolean column — migrate it when
  you declare it. Attempt-history resources gain the `test` column in
  this release (the extension itself is new in 2.2).
- **Inbound tracking (opt-in).** Declaring `ingress_tracking :on` on an
  inbound ledger injects the `duplicates` counter column and the
  `failed_verification` status row (payload-less) — migrate the column
  when you declare it. `previous_secret`/`paused` are declaration-level
  options (no migration).
- **The event log (opt-in).** Create a resource with the new
  `AshHooks.OutboundEvent` extension (needs `timestamps()`; the migration
  carries the table plus the `unique_event` index on `[:event_uuid]`),
  then declare `events YourResource` on each outbound declaration that
  should record. Nothing records without the declaration.
- **Subscription attribute filters (opt-in).** Declaring a nonempty
  `filter_attributes` list on the subscription resource injects the
  `event_filters` column — migrate it when you declare it.
- **Payload-version pinning (opt-in).** Declaring `version_pinning :on`
  on the endpoint resource injects the `pinned_payload_version` column —
  migrate it when you declare it. Dispatch then resolves each endpoint's
  payload through the declaration's `payload_versions` variant builders.
- **Secret rolling (opt-in).** Declaring `key_lifecycle :on` on the
  endpoint resource injects six timestamp columns
  (`secret_created_at`, `secret_first_used_at`, `secret_retired_at`,
  `previous_secret_created_at`, `previous_secret_first_used_at`,
  `previous_secret_retired_at`) — migrate them when you declare it, and
  backfill `secret_created_at` for incumbent keys whose creation time you
  know. Rolling then works through `AshHooks.Endpoint.roll_secret/2` and
  the expiry sweeps.
- **Resend and bulk replay (opt-in).** Declaring `resend_tracking :on`
  under `outbound_delivery` injects four machine columns
  (`resend_baseline`, `resend_count`, `last_resend_by`, `last_resend_at`)
  — migrate them when you declare it — and unlocks
  `AshHooks.Delivery.resend/2` / `replay/2`. Attempt ceilings are now
  series ceilings: a resent row's ladder restarts at its baseline while
  the lifetime `attempts` counter never resets (attempt-history identity
  stays sound). Resources without the columns keep the exact pre-2.2
  ceiling semantics.

## 2.0.4 → 2.1.0

No schema or DSL changes. Two observable deltas:

- **Unresolvable DNS at the send-time destination check now retries.** In
  2.0.4 a hostname that failed to resolve (resolver outage, congestion past
  the 2-second resolution ceiling, or a dead domain) dead-lettered
  immediately as `unsafe_destination` at `attempts == 1`. In 2.0.5 it
  retries as transport and dead-letters at the row ceiling carrying an
  honest label: `nxdomain` (every queried address family answered
  authoritatively negative) or `resolve_timeout` (outage, congestion,
  mixed evidence); the HTTP adapter's umbrella for the same failures is
  `unresolved_host` (all three are in the telemetry reason vocabulary).
  A validated-unsafe answer (private/special-purpose IP) still dead-letters
  immediately as `unsafe_destination`. If you branched on the immediate
  dead-letter to detect DNS-dark endpoints, read the labeled rows off the
  ceiling instead.
- **`use AshHooks.Worker` refuses misfit budgets at compile time.** Oban's
  `:max_attempts` must exceed `:delivery_max_attempts`; a literal
  `:http_opts` `timeout:` must stay below `:attempt_timeout`; budget
  options must be positive integers; `:max_backoff_seconds` must be at
  least `:base_backoff_seconds`. A literal `:http_opts`
  `validate_destination: false` refuses to compile outside `:test` (it is
  the loopback-listener test seam; with it baked in, the driver's send-time
  check is the only remaining SSRF layer). Configs that compiled in 2.0.4
  while silently truncating the retry ladder, walling off slow sends, or
  disabling adapter pinning now raise `ArgumentError`.

## 1.x → 2.0.1

2.0 changes the durable delivery schema and HubSpot's default event identity.
Drain old jobs and migrate before activating the new runtime. Mixed 1.x/2.x
workers against one ledger are unsupported.

### Ordered deployment

1. Quiesce outbound producers, ingress, workers, inbound reapers, and recovery
   schedulers. Drain in-flight 1.x Oban jobs. Record pending rows, retry times,
   tenant partitions, declaration ownership, and the current queue binding.
2. Upgrade to `{:ash_hooks, "~> 2.0"}` with Ash >= 3.34.3 and < 4.0. Generate
   and inspect the AshPostgres migration for every resource carrying either
   delivery extension. Preserve existing endpoint/event and inbound dedup indexes.
3. Add the outbound columns below and extend any database status constraint to
   admit `disable_pending`. Add `superseded` to the inbound status constraint.
   New generated actions are machine primitives: keep application write actions
   narrow and update any explicit action policies before activation.
4. Backfill each existing outbound row's `dispatch_source` and `dispatch_route`
   from its actual emitting declaration, endpoint resource, and enqueue binding.
   Keep attempts and `next_attempt_at`; expired sends need recovery, rather than
   counter resets. Unresolved declaration or route mappings block activation.
5. If a HubSpot declaration uses the former digest default, adopt retained
   identities as described below while ingress and reapers remain quiesced.
   Declarations with an explicit `event_id` extractor keep that extractor.
6. Deploy all 2.0 application nodes/workers together. Enable the periodic
   recovery call for each declaration and tenant, then resume ingress and producers.
   Observe row transitions, persisted runnable jobs, endpoint-disable events, and
   a signed delivery through the actual receiver.

### Outbound columns and ownership

| Attribute | Ash type | Migration requirements |
| --- | --- | --- |
| `dispatch_source` | `:string` | Non-null; max length 1,024; explicit legacy backfill |
| `dispatch_route` | `:string` | Non-null; max length 1,024; explicit legacy backfill |
| `attempt_token` | `:uuid` | Nullable; non-writable |
| `send_lease_expires_at` | `:utc_datetime_usec` | Nullable; non-writable |
| `enqueue_token` | `:uuid` | Nullable; non-writable |
| `enqueue_lease_expires_at` | `:utc_datetime_usec` | Nullable; non-writable |
| `endpoint_snapshot` | `:map` | Nullable; non-writable; JSON storage |

For a declaration and named worker, derive backfill values through
`AshHooks.OutboundBinding.source/3` and `named_route/2`:

```elixir
source = AshHooks.OutboundBinding.source(MyApp.Order, :order_paid, MyApp.WebhookEndpoint)
route = AshHooks.OutboundBinding.named_route(MyApp.WebhookDeliveryWorker, :enqueue)
```

Apply those values only to the reviewed declaration/tenant partition. The
declaration and endpoint module names are part of the versioned identity; renames
require an explicit mapping. Do not infer ownership from current subscriptions.
The default `"v1:direct:unbound"` / `"v1:route:unbound"` markers preserve direct
`:dispatch` action compatibility; they do not identify a legacy declaration.

Named MFA enqueue callbacks and equivalent external captures share a route.
Anonymous callbacks still dispatch; use a stable `enqueue_key` to enable automatic
recovery. An unkeyed anonymous route requires an explicit host mapping. A deferred
declaration dispatched with `enqueue: nil` can bind its route once during recovery.
Keep any keyed callback bound to the same implementation in the host application.

Send claims and result writes use a UUID token, separate from the writable
accounting counter `attempts`. A live send lease blocks competing claims; stale
results cannot mark success, retry, or disable an endpoint. Delivery over the
network remains **at-least-once**: a peer may accept a request before a process
dies or its lease expires. Receivers and inbound handlers need idempotency.

Lease timestamps use application UTC time. Synchronize clocks across application
nodes; expiry and due-time decisions require that deployment prerequisite. The
default attempt budget is 25 seconds plus a 5-second finalization allowance;
the generated Oban timeout is 35 seconds and must exceed their sum. Configure
`attempt_timeout`, `finalization_allowance`, and `timeout` together.

`reconcile_pending/3` now also recovers due retryable failures, expired sends,
enqueue failures, and pending-disable obligations. It preserves attempts and
retry timestamps. Call it periodically per declaration/tenant using the matching
durable route. A 410 stores `disable_pending` before the endpoint write; it is
not terminal until the matching old endpoint configuration is disabled, gone,
or replaced. A storage error keeps that obligation recoverable without resending.

### HubSpot identity adoption

The new HubSpot identity hashes a canonical whole batch. It ignores only outer
`attemptNumber` values, sorts object keys and outer events, preserves batch
multiplicity, and preserves order inside nested lists. Other changed event
content remains a distinct event. The precedence is explicit declaration
`event_id` extractor → provider `event_identity/1` → raw-body digest when the
provider does not implement the callback. A callback error never becomes a digest.

Plan each provider/scope/tenant partition and retain its audit before applying:

```elixir
opts = [tenant: tenant, scope: %{account_id: account_id}]
{:ok, plan} = AshHooks.Ingress.plan_legacy_identity_adoption(MyApp.InboundLedger, :hubspot, opts)
# Review plan.audit; resolve every item in plan.unresolved and plan.conflicts.
{:ok, applied} =
  AshHooks.Ingress.adopt_legacy_identity(MyApp.InboundLedger, :hubspot, Keyword.put(opts, :quiesced?, true))
```

Within a canonical group the representative is processed first, then recoverable,
then permanently failed, with deterministic insertion/key tie-breaking. The
representative receives the canonical identity; siblings become terminal
`:superseded`. Every original payload and digest stays stored. The returned audit
contains before/after keys, identities, statuses, digests, and representative
mapping; persist it in your own upgrade records. Adoption never invokes a handler.
Redacted/unavailable payloads require explicit `canonical_ids` mappings, keyed by
the old external event ID. Unresolved rows and canonical-identity conflicts block
the transaction. The data layer must support transactions; otherwise adoption returns
`{:error, :transactions_not_supported}` without changing rows. Re-plan after applying
to verify stable state. Run each
partition with ingress/reapers stopped; `quiesced?: true` is an assertion by the
operator, not an application-wide lock.

A domain provider wrapping the built-in HubSpot provider must delegate
`event_identity/1` along with its signature/type callbacks:

```elixir
defdelegate event_identity(payload), to: AshHooks.Provider.HubSpotV3
```

That module exists only in 2.x. In 3.0, implement the same identity in your own
provider, as described in the 2.x → 3.0.0 section.

Return a successful provider acknowledgment for `:processed`,
`:failed_permanent`, and `:superseded`. Send permanent errors to your operator
surface; repeated provider retries cannot repair a terminal row.

### Resource and security compatibility

- Ledger operations support complete custom primary-key maps. Endpoint and
  subscription references require a single UUID-storage-compatible key, including
  a renamed UUID/UUIDv7 key. Incompatible/composite reference keys fail at compile.
  Every ledger key component must be generated, defaulted, or supplied by its
  injected create action; unavailable key inputs fail at compile.
- Endpoint mapped enabled/disabled values are cast using the attribute's real
  type/constraints. Empty enabled values, semantic overlap, invalid values, and
  mapping any primary-key attribute fail at compile.
- Event IDs and HTTP headers reject control bytes and invalid UTF-8. Dispatch
  validates IDs on manually constructed event structs too. Event types remain
  nonempty atom/string values bounded to 255 bytes. Arbitrary telemetry reason text becomes
  `unclassified`; use the documented reason vocabulary.
- The default HTTP adapter shares one deadline across DNS, connect, send, and reads.
  Its body cap ends reading immediately; interim 1xx responses precede the final
  response. Special-purpose IP ranges are rejected and IPv6 Host values are bracketed.

## 1.2.1 → 1.3.x

**Nothing breaks and nothing is required.** This release is additive:
new per-resource DSL options (`payload_attribute`, `prune_action`, the
`endpoint` mapping section), docs, and CI. Two behavior notes worth
knowing even if you change nothing:

1. **Generated (non-writable) primary keys now compile.** Resources
   declaring `uuid_v7_primary_key` (or any non-writable `:id`) previously
   failed Ash's `ValidateAccept` on the injected `:dispatch`/`:ingest`
   accept lists. Those resources now compile and classify
   created/duplicate by an identity pre-read. Storage uniqueness preserves the
   row; it does not guarantee one network side effect. Version 2.0 adds durable
   attempt and enqueue ownership. Receivers still need webhook-ID deduplication.
2. **The send path dead-letters an endpoint whose status is anything
   other than `:enabled`** (previously only an exact `:disabled`
   dead-lettered). Only affects consumers who redeclared `status` with
   extra values — the fail-closed direction.

New options, all opt-in: rename the exact-bytes column
(`payload_attribute`), omit the retention destroy action
(`prune_action :none`), map the durable enable/disable onto your own
switch (`endpoint do status_attribute ... end`), and atom-typed
subscription registers now match. The README's "Fitting the extensions
to your domain" section shows each.

## 1.1.1 → 1.2.x

### Multi-tenancy is available and opt-in (ADR-0011)

Nothing changes unless you declare multitenancy on the four resources
(Subscription, Endpoint, both ledgers). If you do, read the adoption
checklist (`documentation/tutorials/tenancy-adoption-checklist.md`) —
the ordered transition for populated tables is **backfill the tenant
attribute → regenerate identity indexes → enable multitenant
dispatch**. A NULL-tenant legacy row forms a shadow partition: new
tenant-bearing upserts create parallel rows and allow repeated processing of
the same logical event.

Two obligations for multi-tenant adopters:

1. **Drain in-flight 1.1.x Oban jobs before serving multitenant
   dispatch.** Pre-tenancy job args carry no tenant and fail closed
   (`{:error, :tenant_required}`) against multitenant resources —
   correct, but noisy. Drain first.
2. **String tenants are the supported job-args shape.** The worker
   serializes the row's tenant into Oban args (JSON), inverting the
   attribute value through the resource's `tenant_from_attribute`. A
   custom `parse_attribute` should pair with `tenant_from_attribute`
   (the default inverse is identity).

New heads are additive: `reap/2`, `redact_payload/5`, `mark_processed/4`,
`mark_failed/6`, `renew/4`, `claim_delivery/3` gained an optional
`opts` (or `:tenant` for the prunes); all prior arities keep working.
The `%{endpoint_id, subscription_id, status, error}` dispatch result
container is now a typespec'd public contract with one NEW status:
`:reconciled`.

## 1.0.4 → 1.1.x

### Elixir 1.20+ required (previously 1.17+)

The supported Elixir window is now `~> 1.20`. Applications resolving
ash_hooks on Elixir 1.17–1.19 get a hard resolver error at deps
loadpaths instead of a compile. Per ADR-0010 rule 4 a supported-floor
bump ships as a MINOR release — so a `~> 1.0` pin will happily resolve
1.1.0 and then fail resolution on old Elixirs. If you cannot move to
Elixir 1.20 yet, pin the floor release instead:

```elixir
{:ash_hooks, "~> 1.0.4"}
```

## 1.0.3 → 1.0.4

Behavior corrections (all also under "Fixed" in the CHANGELOG; no API change):

### 1. Event ids and types are bounded by BYTES, not characters

`AshHooks.Event.new/1` and dispatch previously accepted ids and types up to
255 *characters* (graphemes). Long multi-byte values could pass that check
and then fail the delivery write — under Ash 3.33's `:codepoints` counting,
every endpoint's dispatch errored on an event the library had validated.
Ids and types are now rejected above 255 **bytes** at `Event.new/1`, with a
clear error. If you build event types from multi-byte text, values between
255 characters and 255 bytes now fail fast at construction — which, under
`:codepoints`, previously failed (less clearly) at dispatch.

### 2. Captured snippets and error fields are byte-capped

The 2048-character snippet cap and 255-character error-summary caps counted
graphemes; they now cap **bytes** (on a codepoint boundary). Captured
diagnostic snippets of multi-byte content come out slightly shorter, and a
hostile response body built from combining characters can no longer crash
the post-send ledger write — the same applies to thrown/exit error
classifications.

### 3. Handler failures with invalid-UTF-8 binaries still record

A handler returning `{:error, :retry | :permanent, term}` where `term` is
invalid UTF-8 previously made the failure-recording write itself fail, so
the delivery stayed re-drivable with no record. It now records `[binary]`
as the error class.

## Ash 3.33+: the required `default_string_length_count` config

Ash 3.33 made `config :ash, :default_string_length_count` REQUIRED for
every application that compiles Ash resources — resource compilation
fails until it is set. This is an Ash-level requirement (part of the fix
for GHSA-cwjv-574p-59f6, where grapheme-based counting let values built
from unbounded combining characters through `max_length` limits), not an
ash_hooks one; ash_hooks writes no `:ash` configuration for you. Set it
in your application's `config/config.exs`:

```elixir
# Recommended: counts unicode codepoints, so max_length bounds value
# size and validation matches how SQL data layers count.
config :ash, default_string_length_count: :codepoints

# Keeps pre-3.33 behavior: graphemes are counted when validating in
# Elixir; a single grapheme can carry unboundedly many codepoints, so
# max_length does not bound the size of a value.
config :ash, default_string_length_count: :mixed
```

ash_hooks works under both. One nuance worth knowing: the fields
ash_hooks injects onto ledger and delivery resources carry `max_length`
constraints (event ids and error summaries at 255, response snippets at
2048). Under `:codepoints` those bounds limit codepoints; under
`:mixed`, Elixir-side validation of the same constraints counts
graphemes — the exact tradeoff Ash documents for your own attributes.
The diagnostic response-snippet capture is capped in bytes (on a
codepoint boundary), so a captured snippet always satisfies its
constraint under either mode. Your application owns the choice. See
Ash's
[backwards-compatibility config guide](https://hexdocs.pm/ash/backwards-compatibility-config.html#default_string_length_count)
for per-attribute overrides.

## 1.0.1 → 1.0.2

Two behavior corrections to know about (both security-posture fixes; no API change):

### 1. The alternate `:httpc` adapter refuses literal-IP HTTPS

`AshHooks.Http.Httpc` (NOT the default) now returns `{:error, :ip_literal_https_needs_bounded}`
for `https://<ip-literal>` destinations. It previously validated only the chain — which let
any chain-valid certificate authenticate the endpoint IP. The default adapter
(`AshHooks.Http.Bounded`) enforces the iPAddress-SAN floor and keeps working; if you swapped
to `:httpc` AND deliver to literal-IP HTTPS endpoints, switch those deliveries back (or drop
the `:http` override).

### 2. `use AshHooks.Worker` no longer drops `:http_opts`

`http_opts:` was accepted and silently ignored; it now threads to the adapter. A config that
passed it with a wrong shape could start behaving differently (correctly) — see the `:cacerts`
seam in the README/CHANGELOG for the intended use (private-CA bundles: compile-time literals,
or `{m, f, a}` resolved per-perform for computed values).

## 0.2.x → 1.0.0

1.0.0 is the semver freeze (ADR-0010). There are **no public API removals or renames**
from 0.2.x — upgrading is a version bump plus three behavior corrections to know about:

### 1. Truncated chunked bodies now retry (they previously "succeeded")

`AshHooks.Http.Bounded` (the default adapter) returns `{:error, :truncated_body}` when a
chunked response ends early — exactly as it already did for Content-Length responses. In
0.2.x the chunked path returned a partial body as success, which could mark a delivery
`:succeeded` on partial bytes. If a receiver of yours streams chunked responses and
closes mid-body, deliveries now retry instead of silently truncating.

### 2. `AshHooks.Delivery.prune/2` returns `{:error, error}` instead of raising

Calling it on a delivery resource without `inserted_at` now returns the same error-tuple
contract as `AshHooks.Ingress.prune/2` (the `@spec` always promised this shape). If you
rescued the old `ArgumentError`, replace it with an `{:error, error}` match.

### 3. Literal-IP https endpoints actually work now

The literal-IP certificate check (IP must appear in the certificate's iPAddress SAN,
ADR-0009) was dead-on-arrival in 0.2.x — it rejected **every** literal-IP https endpoint
fail-closed with `:cert_ip_mismatch`. It now verifies correctly: endpoints whose certs
carry the IP SAN deliver; certs without it still fail closed. No action needed unless
you had worked around the rejection.

### Install constraint

```elixir
{:ash_hooks, "~> 1.0"}
```

### Semver from here

`~> 1.0` now means: breaking changes only in 2.0, deprecations run two minors minimum,
safety corrections ship as fixes even where the defective behavior was depended on
(ADR-0010).
