# Changelog

All notable changes to `@absolutejs/sync`.

This file is generated by `absolute-changelog` from the entries in
`changelog/`. Edit an entry, not this file — and add new ones under
`changelog/unreleased/`.

## 3.3.0 — 2026-11-08

### Added

- **Collaborative text reports edits the server has not confirmed** (`CollaborativeTextOptions`, `CollaborativeTextState`, `createCollaborativeText`)
  `CollaborativeTextState` now has `unsent`, the number of local edits the server has not acknowledged yet (sent and awaiting an ack, or held until the document hydrates), and `refused`, why the server refused the last edit it refused, until a later edit is confirmed. An editor can show "saving" while `unsent` is above zero and "saved" once it is zero, instead of claiming saved as soon as someone types. `createCollaborativeText` also accepts `webSocketImpl`, like `createSyncCollection`.

## 3.2.0 — 2026-11-05

### Added

- **Drizzle collections support explicit refetch mode for metadata-only Postgres revision feeds and projected rows** (`drizzleCollection`, `DrizzleCollectionOptions`)

## 3.1.2 — 2026-11-03

### Changed

- **Sandboxed handlers accept any isolated-jsc 0.x from 0.12.2**
  The optional `@absolutejs/isolated-jsc` peer range is now `>=0.12.2 <1.0.0`, so a new isolated-jsc minor no longer needs a sync release before apps can install it. Sync uses only isolated-jsc's stable sandbox APIs (`resolveIsolatePolicy`, the isolated runner), and its sandbox tests run against each isolated-jsc release it is bumped to; this one is tested with 0.15.0.

## 3.1.1 — 2026-11-03

### Changed

- **Sandboxed handlers accept isolated-jsc 0.14**
  The optional `@absolutejs/isolated-jsc` peer range now allows 0.14. With 0.14, the `cpuMs` that sandboxed-handler metrics report is the isolate thread's CPU time instead of the wall-clock duration, so a handler waiting on a host call is no longer charged for the wait.

## 3.1.0 — 2026-11-03

### Added

- **Sandboxed handlers can require a locked-down isolate** (`SandboxConfig`)
  Sandboxed mutation handlers take `requireLockdown`, passed through to isolated-jsc 0.13+. On the Worker backend, stock Bun lets a handler reach the `Bun` global through indirect eval and load any module with `import()`; AbsoluteJS patched Bun 1.4.4+absolute.2 closes both with `lockdown()`. With `requireLockdown: true`, the handler refuses to run on a Worker isolate that is not locked down and throws `LockdownUnavailableError` instead. Default `false`, so nothing changes unless you set it. The `@absolutejs/isolated-jsc` peer range now allows 0.13; older versions ignore the option.

## 3.0.2 — 2026-10-27

### Fixed

- **Bound pending authentication queues and retire timed-out sockets before late context resolution** (`syncSocket`, `SyncSocketOptions`)

## 3.0.1 — 2026-10-27

### Fixed

- **Read WebSocket buffer usage from the underlying Elysia transport and allow queued temporary backpressure to drain without reconnecting; enforce configured byte limits independently of notifications** (`SyncSocketOptions`)
- **Release late subscriptions after connection close or unsubscribe, reject duplicate in-flight subscription IDs, and prevent sends after close**

## 3.0.0 — 2026-10-22

### Breaking

- **Requires Elysia 2.0.0-rc.0 and @elysia/cron 2.0.0-rc.0** (`createPlatformSyncRuntime`, `scheduled`, `syncCdc`, `syncDevtools`, `syncSocket`)
  Elysia 2.0.0-rc.0 renamed every lifecycle hook to its `on` form and removed `setup`/`cleanup`. sync's peer ranges (`elysia ^2.0.0-beta.6`, `@elysia/cron ^2.0.0-beta.1`) accepted it untested. sync now builds and tests against Elysia 2.0.0-rc.0 and requires `^2.0.0-rc.0` for both; the plugins whose types carry Elysia's are listed below. No sync API changed shape.
  _Migration:_ Upgrade `elysia` and every `@elysia/*` package (including `@elysia/cron`) to 2.0.0-rc.0 or later 2.x, then rename lifecycle hooks in your app: request → onRequest, beforeHandle → onBeforeHandle, afterHandle → onAfterHandle, afterResponse → onAfterResponse, error → onError, parse → onParse, transform → onTransform; setup/cleanup → onStart/onStop.

## 2.33.0 — 2026-10-20

### Added

- **Server reactions without timers: createPostgresSignalReaction (from @absolutejs/sync/postgres) runs durable work on NOTIFY and catches up on (re)connect; the table revision source accepts reconcileMs: false** (`PostgresTableRevisionSourceOptions`)

## 2.32.5 — 2026-09-27

### Fixed

- **Serve more than one syncSocket in an app: each socket plugin is seeded by its path, so Elysia no longer drops the second as a duplicate**

## 2.32.4 — 2026-09-25

### Fixed

- **Support schema-qualified PostgreSQL revision feeds without colliding subscription keys**

## 2.32.2 — 2026-09-24

### Fixed

- **Republish socket authentication fix after npm served metadata but returned 404 for the 2.32.1 tarball**

## 2.32.1 — 2026-09-24

### Fixed

- **Close rejected or stalled socket context authentication without leaking internal errors**

## 2.32.0 — 2026-09-24

### Added

- **Postgres transactional mutation receipts and payload-free committed table revision source**

---

## Earlier releases

## 2.31.0

- Allow platform integrations to provision a WebSocket implementation through
  the existing client runtime transport. This enables credential-isolating
  native socket bridges without changing application `createSyncClient` calls.

## [2.30.0] — 2026-08-26

### Added

- `createSharedSyncSubscriber` (`@absolutejs/sync/client`) and a `shared: true`
  option on `createSyncSubscriber` / `createLiveQuery`: every shared subscriber on
  a page multiplexes over ONE EventSource per endpoint, carrying the union of
  their topics and re-opening only when that set changes. Browsers allow six
  concurrent HTTP/1.1 connections per host and an SSE stream holds one for its
  whole life, so a view with a handful of private live queries could stall every
  other request. On a topic-change reconnect only newly joined members receive
  the open frame (already-hydrated queries do not refetch); a transport reconnect
  re-opens everyone.

## [2.29.1] — 2026-08-26

### Fixed

- `sync` plugin: `resolveTopics` now receives cookies parsed from the raw `Cookie`
  header, with Elysia's typed cookie map layered on top. Elysia 2 materializes
  undeclared cookies lazily, so on the schema-less `/sync` route the typed map
  could be empty and session-gated topic authorization silently resolved to
  nothing.

## [2.26.1] — 2026-08-25

- Initialize newly installed schema components from their declared compatible
  baseline while continuing to adopt the app's legacy logical-version ledger.

## [2.26.0] — 2026-08-25

- Compose application and package-owned local schemas with independent stable
  component IDs and version ledgers. IndexedDB upgrades all required component
  steps across every principal in one transaction and reports retained orphaned
  component ledgers when a pack is removed.
- Add JSON-safe `set-default`, `rename-field`, `remove-field`, and
  `delete-collection` operations. AbsoluteJS builds and service workers can carry
  these generated migrations without serializing executable functions.
- Preserve the 2.25 single-schema API as the `@absolutejs/app` component and keep
  its status shape backward-compatible. Add tests for JSON round trips,
  deterministic multi-pack composition, legacy-ledger adoption, and duplicate
  component rejection.

## [2.25.0] — 2026-08-25

- Add one versioned `SyncLocalStoreSchema` contract shared by web IndexedDB and
  native adapters. Migration steps are contiguous, synchronous and deterministic;
  incompatible upgrades and downgrades fail with typed schema errors.
- Upgrade every IndexedDB principal partition and its logical schema marker in
  one transaction. A transform failure rolls back all collection, mutation and
  version changes, while stable mutation operation IDs cannot be rewritten.
- Expose schema status for doctor/release diagnostics and add conformance coverage
  for multi-account upgrades, compatibility floors, downgrade rejection and
  simulated process-death rollback.

## [2.24.0] — 2026-08-25

- Add exact-same-origin HTTP-only session authentication for the finite PWA
  transport when the Absolute Auth capability is mounted. Bearer/native work
  remains unchanged; cross-origin, missing-Origin, non-JSON, and Fetch Metadata
  mismatches fail closed.
- Add the no-store `POST /__absolute/sync/principal` bootstrap, which returns
  only Auth's opaque account namespace after the same request-boundary checks.
- Let `runHeadlessSync()` discover safely resumable, `id`-keyed collection
  descriptors from the principal's transactional store and set
  `redirect: "error"` on every finite exchange.
- Extend the portable local-store contract with namespace-scoped collection
  enumeration for IndexedDB, memory, and native SQLite adapters.
- Allow browser runtime transports to omit socket tickets so authenticated web
  sessions can keep using their existing cookie transport.

## [2.17.0] — 2026-08-25

- Add `createIndexedDbSyncLocalStore`, a real browser/PWA implementation of the
  unified local transaction contract. It atomically stores principal-scoped
  installation identity, confirmed multi-collection rows/cursors, and the
  outbound operation queue.
- Add the opt-in `createSyncClient({ durable })` profile. The multiplexed client
  now hydrates offline rows before subscribing, persists consistent frames in one
  transaction, reconstructs serialized optimism after process death, and replays
  the same operation ID until an identity-matched acknowledgment removes it.
- Add serializable insert/update/delete optimistic operations with automatically
  captured inverse operations. Existing optimistic callbacks remain compatible
  as an explicitly process-local tier.
- Keep old clients and stores compatible: the non-durable path remains
  synchronous and unchanged, and 2.16 operation records without `owner` migrate
  from their first optimistic collection.
- Run one local-store conformance suite against both memory and IndexedDB, plus
  durable client tests for restart replay, cursor hydration, cross-collection
  persistence, account boundaries, and fail-closed acknowledgment matching.

## [2.16.0] — 2026-08-25

- Add stable string `operationId` support to mutate/ack/reject frames while
  preserving the legacy numeric correlation id and wire behavior.
- Add the server-owned `durableMutations` engine contract. Its adapter runs the
  mutation's table writes and deduplication receipt in one database transaction,
  scopes receipts from authenticated context, and returns the committed result
  without re-running effects after a lost acknowledgment.
- Add the framework-neutral `SyncLocalStore` transaction contract for confirmed
  rows, cursors, installation identity, and serializable optimistic outbox
  records. The in-memory reference adapter proves atomic rollback and principal
  namespace isolation; IndexedDB and Capacitor SQLite adapters can share the same
  conformance model.
- Add stable installation/operation identity helpers and regression coverage for
  legacy delivery, replay, rollback, account isolation, and protocol forwarding.

## [2.13.3] — 2026-08-12

- Preserve exponential reconnect backoff across sockets that open but never
  receive a valid Sync frame. A healthy server frame still resets the delay,
  while graceful-drain reconnect behavior remains unchanged.

## [2.13.2] — 2026-08-10

- Add `createSyncSocketController()` so blue-green hosts can permanently drain
  an old Sync endpoint with WebSocket code 1012, close current connections
  cleanly, and reject late connections while clients reconnect to the new slot.

## [2.13.0] — 2026-07-27

- Collaborative text subscriptions now accept collection `params`, allowing
  document-scoped hydration and authorization instead of loading an entire
  document table for every editor.
- Collaborative text state exposes `ready` after the authoritative row
  hydrates. Edits made during connection setup are buffered and reconciled
  after hydration, preventing a fast typist from forking an empty replica.
- React, Vue, Svelte, and Angular bindings surface the same readiness contract.

## [2.8.0] — 2026-07-17

- Connection brokers now support `affinity: 'tenant'` for BYO database
  credentials. Idle connections are reused only by their owning tenant, the
  tenant is passed to `create`, and `maxTotal` remains a hard ceiling across
  active plus idle physical connections.

## [2.7.1] — 2026-07-16

- Export `PlatformSyncHealthSchema` and its static type so hosts validate the
  managed readiness contract and release identity without redefining it.

## [2.7.0] — 2026-07-16

- The platform-managed runtime now owns first-class Sync pack registration and
  cluster-bus connection lifecycle through `packs` and `clusterBus`.
- Runtime readiness stays closed until the cluster subscription connects and
  reports the connected cluster posture plus registered packs for operators.
- `runtime.ready` and idempotent `runtime.dispose()` remove manual startup and
  shutdown wiring from hosted applications.

## [2.6.0] — 2026-07-16

- Topic authorization receives Elysia-decoded cookie values, so signed session
  cookies can gate live subscriptions without each host reimplementing cookie
  parsing or signature handling.

## [2.5.0] — 2026-07-16

- `sync({ resolveTopics })` now accepts asynchronous authorization, allowing
  database-backed sessions to resolve their permitted SSE topics before the
  stream opens.

All notable changes to `@absolutejs/sync` are recorded here. The format is loosely
based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project
follows [Semantic Versioning](https://semver.org) from 1.0 onward.

## [2.3.0] — 2026-07-13

### Added — `createConnectionBroker` (BYO-Postgres connection multiplexing)

One shard hosting 50 customers, each spawning its own PG pool,
instantly exceeds a managed provider's connection limit. The new
broker multiplexes ONE upstream connection budget across many tenant
logical DBs — no pgbouncer sidecar. Generic over `Conn`: the broker
never imports a DB driver, `create`/`destroy` are caller-supplied
(postgres-js, `Bun.sql`, anything).

- **`createConnectionBroker<Conn>(options)`** — new root export.
  Options: `create` (required), `maxTotal` (required global in-use
  cap, > 0), `maxPerTenant?`, `acquireTimeoutMs?`, `idleReleaseMs?`,
  `validate?`, `destroy?`, `onError?(err, phase)`, `now?` (injectable
  clock), `tracerProvider?`.
- **`broker.lease(tenant)`** → `{ conn, release() }`. At cap, callers
  queue FIFO and are handed a released connection immediately; idle
  reuse is LIFO for cache warmth; `release()` is idempotent.
- **`broker.withLease(tenant, fn)`** — lease, run, release in
  `finally`.
- **`broker.drain()`** — stop new leases (rejects with the new
  `ConnectionBrokerDrainedError`), serve the existing queue through,
  resolve when in-use hits zero. **`broker.dispose()`** — drain-if-
  needed, reject queued waiters, destroy idle connections; leased
  connections are destroyed on their eventual release.
- **`broker.metrics()`** — operator-shaped like `engine.metrics()`:
  `{ inUse, idle, queued, byTenant, cumulative: { leases, releases,
timeouts, created, destroyed, validationFailures } }`.
- **Idle harvesting** — pooled connections unused for `idleReleaseMs`
  are destroyed, on an unref'd timer AND lazily on every lease (the
  injected `now` makes this testable without timers).
- **Health-checked reuse** — `validate` runs on every pooled reuse;
  `false` (or a throw) destroys the connection and serves the lease
  from a fresh create, so a server-side idle disconnect never reaches
  a caller.
- **Typed errors** — `LeaseTimeoutError` (`{ tenant, timeoutMs }`)
  when `acquireTimeoutMs` elapses; `ConnectionBrokerDrainedError`
  after drain/dispose. Both exported from the root.
- **OTel** — with a `tracerProvider`, every lease is traced as a
  `sync.broker_lease` span carrying `abs.tenant` and
  `abs.broker.queue_wait_ms`. Noop (zero-cost) when unset.

```ts
const broker = createConnectionBroker({
	create: () => postgres(DATABASE_URL, { max: 1 }),
	destroy: (sql) => sql.end(),
	maxPerTenant: 3,
	maxTotal: 20
});
const rows = await broker.withLease(
	tenantId,
	(sql) => sql`select * from orders where tenant = ${tenantId}`
);
```

13 new tests in `tests/connectionBroker.test.ts`, including a
50-lease storm over `maxTotal: 5` asserting the cap never breaches
and the whole storm rides 5 physical connections.

## [2.2.2] — 2026-06 (backfilled 2026-07-13)

- **Package manifest** — ships the `@absolutejs/manifest` contract v1:
  a `./manifest` subpath with the settings schema (drift-checked
  against the composite `SyncPluginOptions` / `SyncEngineOptions` /
  `SyncSocketOptions` / `SyncDevtoolsOptions`), five wiring recipes
  (SSE push, ORM live-query, sync engine, collaborative text,
  cluster), runtime AI tools over `{ engine, hub }` (engine_overview,
  engine_metrics, replay_at, run_schedule, publish_topic), and two
  adapter contract ids with bundled defaults: `sync/crdt-adapter`
  (rgaText) and `sync/cluster-bus` (createInMemoryClusterBus).
  `absolute-manifest emit` writes `dist/manifest.json` at build.

## [2.2.1] — 2026-06 (backfilled 2026-07-13)

- npm support metadata (homepage / bugs) + pending local changes.
  No functional change.

## [2.2.0] — 2026-06 (backfilled 2026-07-13)

- **Affects gate** — optional `CollectionDefinition.affects(change,
params, ctx)` for refetch-fallback collections (multi-table views,
  or views where the change row isn't the collection's `T` so `match`
  can't apply). The engine skips re-hydrating subscriptions a change
  provably can't touch: fan-out drops from O(all subscribers) to
  O(affected). Conservative — defaults to affected when unsure;
  ignored when `match` is set.

## [2.1.0] — 2026-06 (backfilled 2026-07-13)

> **Note on the major bump:** there was no 2.0.0 release and no
> breaking change. The version rolled 1.24.0 → 2.1.0 alongside the
> first public npm publish (BSL 1.1 license + support metadata). The
> public API is unchanged from 1.24.0.

- **Change-source liveness** — `engine.metrics().source` reports
  `{ connected, changesReceived, lastChangeAt, lastChangeAgeMs }`
  aggregated across every `connectSource`, so a health check can
  distinguish a wired-but-silent CDC feed (`connected` with
  `changesReceived === 0`) from a healthy one, and external alerting
  can catch a feed that has gone quiet.

## [1.24.0] — 2026-05-30

### Added — G7 tenant migration primitives (`fence` / `exportSnapshot` / `importSnapshot`)

Closes G7 from the deep-research audit. The "move a tenant from
engine A to engine B" story becomes a substrate primitive — three
composable verbs that operators wire together.

- **`engine.fence({ reason })`** — pause new mutations on the source
  so its captured state stops drifting. `runMutation` rejects with
  the new `EngineFencedError` (`{ reason }` propagates). Reads
  (subscribe/hydrate/streamChanges) continue to work so live
  subscribers don't go dark during the transfer. Returns a
  `FenceHandle` with `lift()`; multiple fences compose — the engine
  unfences only after every handle has been lifted. `lift()` is
  idempotent.
- **`engine.exportSnapshot({ tables?, ctx? })`** — walks every
  registered reader's `all(ctx)` and returns a portable
  `EngineSnapshot` `{ sourceInstanceId, version, exportedAt, tables
}`. Optionally narrowed to a subset of tables. Detached from
  `ChangeLogSnapshot`: snapshots carry live state, not history.
- **`engine.importSnapshot(snapshot, { tables?, onProgress?, ctx? })`**
  — on the target, bulk-loads via each table's registered writer.
  Per-table progress callback fires for every row. Tables in the
  snapshot with no writer on the target are surfaced in
  `result.skipped` so a misconfigured target doesn't silently drop
  data. Returns `{ tablesImported, rowsImported, perTable, skipped }`.

```ts
const fence = source.fence({ reason: 'tenant-7 → us-east-2' });
try {
	const snapshot = await source.exportSnapshot();
	await transport(snapshot); // S3, message bus, etc.
	await target.importSnapshot(snapshot, {
		onProgress: (table, done, total) =>
			console.log(`${table}: ${done}/${total}`)
	});
} finally {
	fence.lift();
}
```

**Out of scope** (caller's responsibility): out-of-band writes
(CDC drivers, raw SQL). The fence only blocks mutations going
through `runMutation`; if you're driving the engine from CDC, halt
the CDC pipe before fencing.

12 new tests in `tests/migrate.test.ts`:

- runMutation throws EngineFencedError while fenced
- subscribe + hydrate continue while fenced
- multiple fences compose; engine unfences only after every lift
- lift() is idempotent
- snapshots every reader by default
- narrows to the requested tables
- reports the source engine version
- rehydrates the target engine via its writers
- reports tables with no writer in `skipped`
- honors the tables filter on import
- fires onProgress for each inserted row
- end-to-end cross-region tenant move preserves data

Test count: 581 → 593.

## [1.23.0] — 2026-05-30

### Added — `syncDevtools` point-in-time replay surface

Wires the 1.22.0 `engine.replayTo()` API into the live devtools
dashboard. Operators get a clickable surface to reconstruct tenant
state at a target timestamp without writing code.

- **`GET <path>/replay?at=<ms>&tables=<csv>`** — JSON endpoint that
  parses the query, calls `engine.replayTo({ at, tables })`, and
  returns the full `ReplayResult`. Returns `400` on missing/malformed
  `at`; `500` (with `{ error }` body) on engine throws.
- **Dashboard "Point-in-time replay" section.** New panel with a
  `datetime-local` picker (defaults to 1 hour ago), a "tables" CSV
  filter, a "max rows per table" cap (1–500), and Replay / Now
  buttons. Results render with `asOfVersion`, formatted `asOfAt`, a
  truncated-warning banner when `truncated: true`, and a per-table
  collapsible pane (row count + first N rows in formatted JSON).
- **Composes with custom mount path.** `syncDevtools({ engine, path:
'/_admin/sync' })` exposes the replay endpoint at
  `/_admin/sync/replay` automatically.

5 new tests in `tests/devtoolsReplay.test.ts`:

- dashboard HTML serves at the configured path and references the
  replay/stream URLs
- replay returns JSON with reconstructed rows at a timestamp
- `tables` CSV filter narrows the result
- missing or malformed `at` returns 400
- custom mount path threads through to the replay endpoint

Test count: 576 → 581.

## [1.22.0] — 2026-05-30

### Added — `engine.replayTo({ at, tables? })` — tenant point-in-time replay

Closes G6 from the deep-research audit. The Convex-differentiator
pitch: "I deleted prod, restore us to 2h ago." Forensic incident
response: "What did the tenant see at 14:32?"

- **`engine.replayTo(options)`** returns `Promise<ReplayResult>` —
  walks the change log forward to `options.at`, folds each op
  (`insert` / `update` / `delete`) into a per-table keyed view, and
  returns `{ asOfVersion, asOfAt, rows, truncated }`.
- **`options.tables`** narrows the reconstruction to a subset — useful
  when you only need "what did `orders` look like" without paying to
  reconstruct every table the engine knows about.
- **`truncated`** is `true` when the log has been trimmed past the
  target (the oldest retained entry is version > 1 AND its `at` is
  past `options.at`). In that case the result is the state walked
  forward from the OLDEST retained entry — best-effort given the
  retention window. The caller should treat it as approximate and
  surface the truncation to operators.
- **Composes with `exportChangeLog` / `importChangeLog`** — replay on
  a restored engine reconstructs against the imported log. The
  replay test for snapshot-import → replayTo-mid is in
  `tests/replayTo.test.ts`.

**Limitations.** The reconstruction's accuracy is bounded by
`changeLogSize` + `changeLogRetainMs`. Set these wide for forensic
use cases (e.g. `changeLogRetainMs: 14 * 24 * 60 * 60 * 1000` for a
14-day forensic window).

11 new tests in `tests/replayTo.test.ts`:

- empty log returns empty rows
- insert sequence reconstructs both rows
- update — later state wins
- delete removes the row
- targetAt cuts off later entries
- asOfVersion / asOfAt reflect the last folded entry
- table filter only includes specified tables
- truncated=true when log trimmed past target
- truncated=false when log starts at version 1 (empty pre-history)
- truncated=false when targetAt is in the future
- replay against an `importChangeLog`-restored engine works

Test count: 565 → 576.

## [1.21.0] — 2026-05-30

### Added — OpenTelemetry tracing via @absolutejs/telemetry

Closes G2 from the deep-research audit for the sync engine. Customer
SREs investigating a slow tenant can now follow one trace from the
HTTP request span (via `@elysiajs/opentelemetry`) down into individual
sync mutations and subscriptions.

- **`SyncEngineOptions.tracerProvider?: TracerProvider`** — any
  `@opentelemetry/api`-compatible `TracerProvider`. When supplied,
  `engine.runMutation` and `engine.subscribe` emit named spans with
  `ABS_ATTRS` semantic attributes (`abs.engine.id`, `abs.collection`,
  `abs.mutation`). When omitted, all tracing is a zero-allocation
  noop — existing call sites pay nothing.
- **`sync.runMutation` span** wraps the entire mutation lifecycle
  including retries, the sandboxed-handler path, and the
  `applyChangeBatch` commit. Attributes: `abs.engine.id`,
  `abs.mutation`. Errors recorded via `span.recordException` +
  `ERROR` status.
- **`sync.subscribe` span** wraps the setup cost (authorize / hydrate
  / view materialization). The Subscription lives past this span ending
  — the ongoing reactive lifetime isn't a single span (would be
  unbounded).
- **`@absolutejs/telemetry` is a regular dep, not a peer.** Tiny
  (~250 LOC, zero transitive deps); bundling it avoids consumer-side
  peer-dep gymnastics. The dep adds no runtime cost when `tracerProvider`
  is undefined — the noop tracer is a singleton.

5 new tests in `tests/tracing.test.ts`: captures spans through a mock
`TracerProvider`, verifies the right names + ABS_ATTRS + lifecycle
(success path, throw path, both for `runMutation` and `subscribe`).

Test count: 560 → 565.

## [1.20.1] — 2026-05-29

### Added — subscription backpressure (`subscriptionLimit`)

Symmetric to 1.20.0's mutation backpressure on the read side. A single
tenant opening thousands of subscriptions would otherwise exhaust the
engine's per-subscription bookkeeping (`active` Maps, `tableIndex`,
the reactive cache, per-row diff computation). 1.20.1 adds an optional
per-tenant cap at `engine.subscribe`:

- **`SyncEngineOptions.subscriptionLimit`** —
  `{ max: number; key: (ctx, args) => string | undefined }`.
  Returning a string from `key()` enrolls the call in the cap;
  returning `undefined` exempts it (use for internal / system
  subscriptions that shouldn't count against any tenant).
- **`SubscriptionLimitError`** (new export) — typed error with
  `tenantKey`, `limit`, `active` fields. Thrown BEFORE authorize,
  hydrate, or any subscription state allocation, so a rejected call
  leaks nothing.
- **`engine.metrics().subscriptions.byTenant`** — current per-key
  tally. Empty `{}` when no `subscriptionLimit` is configured.
- The slot is released by the wrapped `unsubscribe`, which is
  idempotent (calling twice is a no-op). Failed `authorize`,
  schema errors, mid-flight aborts, etc. release the slot before
  re-throwing — no leak by one per failed call.
- AbortSignal-driven unsubscribe also releases the slot.

7 new tests in `tests/subscriptionLimit.test.ts`:

- per-tenant cap holds,
- different keys count separately,
- undefined key skips the cap,
- unset option leaves `byTenant` empty (back-compat),
- failed authorize releases the slot,
- `SubscriptionLimitError` carries diagnostic fields,
- abort-triggered unsubscribe releases the slot and is idempotent.

Test count: 553 → 560.

## [1.20.0] — 2026-05-29

### Added — mutation backpressure (`mutationConcurrency` + queue cap)

A single tenant flooding `runMutation` could otherwise drive unbounded
per-call memory growth (actions buffers, retry timers, queued sandbox
invocations). 1.20.0 adds an optional FIFO semaphore at the mutation
entry point so the PaaS host can bound throughput per engine:

- **`SyncEngineOptions.mutationConcurrency: number`** — max in-flight
  mutations (`runMutation` + `runMutations`). Calls beyond the cap
  queue in arrival order and run as slots free up. Unset = unbounded
  (matches pre-1.20 behavior).
- **`SyncEngineOptions.mutationQueueLimit: number`** — bound on the
  waiting queue. Excess calls throw `MutationQueueOverflowError`
  immediately so the gateway can return a clean 429 instead of holding
  the request open. Defaults to unbounded queue.
- **`MutationQueueOverflowError`** (new export) — typed error with
  a `queueLimit` field.
- **`engine.metrics().mutations.queued`** — current queue depth,
  surfaced for the host's per-tenant tier monitoring.

Semaphore semantics:

- A `runMutations` batch counts as **one** slot, regardless of how
  many mutations the batch contains.
- Authorization failures don't burn a slot (the gate runs after
  `authorize`).
- The slot is released in a `finally` so a thrown mutation, a
  retries-exhausted error, an aborted transaction, etc. all properly
  release.
- Increment is atomic with the slot grant (synchronous within
  `acquireMutationSlot`) so concurrent calls can't both pass the
  capacity check.

7 new tests in `tests/mutationConcurrency.test.ts`:

- cap = 2 holds the line at 2 in-flight with 3 queued,
- queueLimit overflow rejects immediately,
- no-setting case is a no-op (back-compat),
- queue count returns to 0 on mutation failure,
- FIFO arrival order preserved through the queue,
- `runMutations` batch = 1 slot,
- unauthorized doesn't consume a slot.

Test count: 546 → 553.

## [1.19.0] — 2026-05-29

### Added — change-log snapshot / restore for shard reboots

The PaaS host needs a way to keep cursor resumability across a shard
restart. 1.17.0/1.18.0 made the engine cluster-aware but tied resume
to _peers being online_; if the engine that minted a cursor went down
and a fresh process started in its place, the local-origin entries
were gone and any cursor referencing them fell back to a fresh
snapshot.

1.19.0 lets the host persist the engine's bounded change log + version
and restore it on the replacement process:

- **`engine.exportChangeLog()`** returns a serializable
  `ChangeLogSnapshot` (`instanceId`, `version`, `entries`,
  `exportedAt`). Cheap — shallow slice of the bounded log; no
  iteration, no permission walk, no view materialization. Call on a
  timer (every 5s) or on `SIGTERM`; both are safe because the log is
  monotonic in commit order.
- **`engine.importChangeLog(snapshot)`** adopts the snapshot into a
  fresh engine (`version === 0`). Throws if `version > 0` (a partial
  restore would re-broadcast the snapshot's contents under the wrong
  version, breaking cursors).
- **`createSyncEngine({ initialChangeLog })`** convenience for the
  boot path — restore happens once at construction before any
  surfaces are registered. The engine's `instanceId` MUST match the
  snapshot's `instanceId`, otherwise construction throws (a wrong-id
  restore silently breaks the resume contract for every existing
  cursor; failing loud is the right default).
- Imported entries respect the receiving engine's `changeLogSize` and
  `changeLogRetainMs` policies — over-large snapshots get trimmed
  exactly as if the entries had been logged live.

7 new tests in `tests/changeLogSnapshot.test.ts`:

- export shape + shallow-copy semantics,
- boot-time restore preserves cursor resumability across reboot,
- restored engine continues to serve cluster resumes (peer entries
  carry through),
- refuses cross-instance restore (wrong `instanceId`),
- refuses post-write import (`version > 0`),
- trims oversized snapshots,
- export is a snapshot (subsequent writes don't mutate it).

Test count: 539 → 546 (+7).

## [1.18.2] — 2026-05-29

### Fixed — peer-only cursor resume

- **Cross-instance cursor resume falsely fell back to snapshot when an
  engine had only peer-broadcast entries in its log.** `canResume`'s
  local-origin branch required `oldestPerOrigin.get(instanceId)` to be
  defined when the cursor's `lastSeen < version` — but `version`
  increments on peer-batch apply too, so an engine that had only
  applied peer changes (and never made local writes since the cursor
  was minted) hit `oldestLocal === undefined` and bailed out to a
  fresh snapshot.

    Fixed by relaxing the local-origin check: when there are no local
    entries in the log, fall through to a log-wide watermark check (the
    log's oldest version must not exceed `lastSeen + 1`). The peer-origin
    walk still independently verifies that every peer's tail is present.

    Surfaced by a mixed-inline+spill cross-instance resume test in
    `@absolutejs/sync-bus-pg`'s integration suite — the second instance
    had logged the peer's two changes but never written its own, and
    the resume path snapshot'd instead of catching up.

## [1.18.1] — 2026-05-29

### Fixed

- **Stale `dist/engine/cluster.d.ts`** missing the 1.17.0
  `ClusterMessage.originVersion` field. The source had it; the published
  type bundle didn't because the build that shipped 1.17.0 / 1.18.0
  carried a cached `.d.ts` from an earlier build. Downstream `ClusterBus`
  adapters (e.g. `@absolutejs/sync-bus-pg`) saw type errors when
  populating `originVersion`. Rebuilt + republished — no source-code
  changes vs 1.18.0.

## [1.18.0] — 2026-05-29

### Added — client-side cursor plumbing

The 1.17.0 cursor primitive now flows end-to-end through every client lib.
Cross-instance resume just works: client connects to engine A, captures
the cursor, reconnects to engine B (different cluster shard), engine B
serves catch-up via peer-broadcasted changes.

- **`OnDiff` callback signature widened** — now receives `(diff, version,
cursor?)`. The cursor is the engine's current cross-instance resume
  cursor at the time of the batch. Pre-1.18 2-arg callbacks keep
  working — the 3rd arg is optional.
- **`ServerFrame.cursor?: string`** — every `snapshot` / `diff` / `frame`
  frame may now carry the cursor. Old servers that don't emit one cause
  the client to fall back to the numeric `version`.
- **`ClientFrame.subscribe.since`** widened to `number | string`. The
  server-side `parseFrame` accepts both; the client lib picks the cursor
  when one has been received, falling back to `appliedVersion`.
- **Client libs (`syncClient`, `syncCollection`, `syncStore`)** now
  capture the cursor from incoming frames and round-trip it on
  reconnect. The `appliedCursor` / `entry.cursor` field shadows
  `appliedVersion` whenever the server has surfaced one.

### Fixed

- **`currentCursor()` was reading `entry.version` instead of
  `entry.originVersion`** when summarizing peer-relayed entries. For
  local-only changes this was a no-op (the two are equal); for cluster
  bus traffic the cursor was emitting THIS engine's local version
  against the peer's id, so a follow-up resume would never match the
  peer's actual log entries. Caught by extending the multi-instance
  test to verify the cursor's contents instead of just its presence.

### Notes

Backwards-compatible — every old client that ignores `cursor` and
sends `since: number` keeps working. The cross-instance resume only
activates when both ends use cursors.

## [1.17.0] — 2026-05-29

### Added — cross-instance resume cursor

The big one: clients reconnecting to a DIFFERENT cluster instance can now
resume with a catch-up diff instead of falling back to a fresh snapshot.
The `cluster.ts` comment that said "use sticky sessions if you want
cross-instance resume" is now obsolete.

- **`SyncEngineOptions.instanceId`** — stable string id. Default: random
  UUID per engine. For a real cluster, pass a stable per-shard value
  (e.g. `${hostname}:${shardId}`) so resume cursors remain decodable
  across restarts.
- **`LoggedChange.origin` + `LoggedChange.originVersion`** — every entry
  now records which engine produced it and that engine's local version
  at commit. Locally-committed changes have `origin === instanceId`;
  cluster-received changes carry the peer's identity.
- **`Subscription.cursor: string`** — opaque resume cursor. JSON-encoded
  vector of `(instanceId, version)` per origin the client has caught up
  to. The client round-trips it on reconnect.
- **`SubscribeArgs.since: number | string`** — `number` is the legacy
  pre-1.17 form (this engine's version); `string` is the new cursor.
  Backwards-compatible.
- **`ClusterMessage.originVersion?: number`** — pre-1.17 buses that omit
  this default to 0 (cross-instance resume falls back to a snapshot —
  matches pre-1.17 behavior). New buses include the originating
  instance's local version, so each engine logs peer changes against
  `(origin, originVersion)` for cross-instance catch-up.

### Why this matters for the PaaS

Without 1.17.0: the @absolutejs/router rotates shards (or load shifts a
tenant between them), the client lands on a different engine, the engine
returns a fresh snapshot. For a tenant with a large dataset that's
expensive bandwidth + a visible UX stall. With 1.17.0: the engine the
client lands on builds a catch-up from peer-broadcasted changes —
exactly the same diff the original engine would have produced.

### Notes

- Single-instance setups (no `connectCluster`) behave identically to 1.16.
- The cursor is opaque. Clients must round-trip it unmodified; the format
  will shift in future versions (HLC, monotonic UUIDs, compressed binary)
  without bumping major.

## [1.16.0] — 2026-05-29

### Added — pluggable wire-format serializer

- **`FrameSerializer` interface + `jsonSerializer` default**, exported from
  `@absolutejs/sync`. The serializer owns the wire format only — frame-shape
  validation stays in the engine, so the SAME validation works for JSON,
  msgpack, cbor, or any binary layout. The default `jsonSerializer`
  preserves every existing call site's behavior.
- **Threaded through every layer:**
    - Server: `createSyncConnection({ serializer })` + `syncSocket({ serializer })`.
    - Client: `createSyncClient({ serializer })`,
      `createSyncCollection({ serializer })`, `syncStore({ serializer })`,
      `createPresence({ serializer })`.
- Both ends MUST use the same serializer; opt into a binary one on BOTH
  ends to cut the bandwidth + parse CPU on large snapshots — the
  customer-app side wins observable bytes-egress + faster cold reads.

### Why this matters for the PaaS

JSON is great until you're sending a 1 MB initial hydrate per reconnect.
At a million reconnect-events/day across tenants, the meter's
`bytesEgress` line item is the actual customer bill — cutting it 40-60%
with msgpack/cbor is real money. This release ships the seam without
prescribing a specific binary encoder; pick the one your client lib
already has and plug it in.

### Notes

- The `decode` step accepts strings, `Uint8Array`, and `ArrayBuffer` —
  Bun's WS gives bytes for binary frames; Browser WS gives ArrayBuffer.
  `jsonSerializer.decode` handles all three by UTF-8 decoding when
  needed.
- A custom serializer's `encodeServer` / `encodeClient` may return
  `string | ArrayBufferLike | Uint8Array`. The WS adapter passes
  through whatever shape the WS impl accepts.

## [1.15.0] — 2026-05-29

### Added — AbortSignal on subscribe + hydrate

- **`SubscribeArgs.signal: AbortSignal`** — first-class cancellation on
  `engine.subscribe`. Two effects:
    1. If the signal is already aborted when `subscribe` is called, the engine
       throws `AbortError` immediately — no authorize, no hydrate, no
       subscription is built.
    2. If the signal fires AFTER the subscription is live, the engine
       auto-calls `unsubscribe()`. The consumer never has to thread two
       handles for the same lifetime.
- **`engine.hydrate(collection, params, ctx, options?)`** — new optional
  4th arg. `options.signal` cancels mid-flight; the engine re-checks the
  signal after each major await (authorize, hydrate body) and throws
  `AbortError` when fired.
- **`AbortError` exported** — `name === 'AbortError'` to match the
  DOM-standard spelling so existing `catch (error) { if (error.name ===
'AbortError') ... }` patterns work unchanged.

### Notes

Real production hazard the signal addresses: a slow hydrate (large search
index warm-up, expensive graph rerun, multi-table join) that started
because the client subscribed, then the client disconnects mid-flight,
and the engine keeps churning CPU on work nobody will ever read.

Backwards-compatible — omit the signal and the engine behaves exactly as
in 1.14.0. Both function signatures already accepted extra arguments
that were unused; nothing breaks at the call-site level.

## [1.14.0] — 2026-05-29

### Added — connection-layer + WS-layer slow-client signaling

- **`connection.stats()`** — point-in-time counters on a `SyncConnection`:
  `{ subscriptionCount, presenceRoomCount, framesSent, slowSendsRecent }`.
  Cheap; safe to call from a metering loop. `slowSendsRecent` counts
  consecutive `send()` calls that returned `-1` (the WS backpressure
  signal), resetting to `0` on the next successful send.
- **`SyncConnectionOptions.send` return type widened** — `send` may now
  return `void | number`. By convention `-1` signals backpressure
  (matches Bun's `ws.send()` return). Legacy void-returning sends keep
  working unchanged.
- **`syncSocket({ maxBufferedBytes, onSlow, closeOnSlow })`** — WS-layer
  slow-client detection. The plugin wraps every `ws.send()` to capture
  the return value AND read `ws.getBufferedAmount()`. If either the
  buffer exceeds `maxBufferedBytes` OR the send returns `-1`, `onSlow`
  fires once with `{ wsId, bufferedAmount, stats, reason }` where reason
  is `'buffer-threshold'` or `'send-backpressure'`. The signal re-arms
  on the WS `drain` event. `closeOnSlow: true` kicks the socket on the
  first slow signal; the client reconnects and rehydrates.

### Notes

The plugin's return type (`Elysia`) is unchanged; new behavior is opt-in
via the new options. Existing callers without `maxBufferedBytes` or
`onSlow` see identical semantics to 1.13.0. Pairs naturally with
`@absolutejs/metering` (wire `onSlow` to charge tenant extra) OR with
`@absolutejs/runtime`'s drain mode (kick slow tenants off a shard about
to reboot).

## [1.13.0] — 2026-05-29

### Added — engine introspection & retention pass

- **`engine.metrics()`** — operator-shaped point-in-time engine state.
  Distinct from `engine.inspect()` (which is devtools-shaped). Returns
  `{ at, uptimeMs, version, changeLog: { entries, capacity, retainMs,
oldestVersion, oldestAgeMs }, subscriptions: { total, byCollection },
reactiveCache: { entries, capacity }, mutations: { completed, failed,
retried, inFlight }, schedules: { registered } }`. Designed for PaaS
  hosts to scrape on an interval and attribute cost per engine via
  `@absolutejs/metering`.
- **`changeLogRetainMs` option** — time-based change-log retention,
  layered on top of the existing count cap (`changeLogSize`). Drops
  entries older than the configured window. Lets a high-throughput
  engine keep a short log ("60s of changes") regardless of mutation
  rate — both bounds memory and bounds catch-up work on reconnect.
  Default `null` (no time-based eviction).
- **Per-mutation counters** — `engine.metrics().mutations.{completed,
failed, retried, inFlight}` accumulate since engine start. The
  `inFlight` counter wraps every `runMutation` call in a try/finally
  so it decrements correctly on the exception path too. Retry attempts
  bump `retried` regardless of whether the eventual outcome is success
  or failure.
- **`LoggedChange.at`** — every entry in the change log now carries the
  wall-clock timestamp it was logged at. Drives the time-based
  retention sweep + the `oldestAgeMs` field on `engine.metrics()`.
  Surfaced on every entry yielded by `engine.streamChanges()`.
  Additive — pre-1.13.0 consumers that destructure `LoggedChange` are
  unaffected.

### Notes

This pass deliberately does NOT touch the connection layer or the WS
hotpath — those are larger surgical changes (slow-client backpressure,
binary frame encoding, cross-instance version cursors) and ship in
1.14.0+. Everything in 1.13.0 is engine-internal, additive, and
backwards-compatible.

## [1.12.0] — 2026-05-29

### Added

- **`SandboxConfig.unsafeHost` escape hatch** — opt-in map of host
  functions a `sandboxedHandler` may call as
  `unsafeHost.fnName(...args)`. Without this option the sandbox stays
  hermetic; with it, the engine routes declared host calls through the
  existing `__dispatch` Reference (no extra IPC primitive) so an
  isolated mutation can reach a payment gateway / queue / SDK / mailer
  when it has to. The name is deliberately loud — anyone reading the
  handler source sees the escape immediately. Convex actions are the
  same pattern; the trade-off is the same: retries WILL re-fire the
  host fn, so make it idempotent or pair with compensation. Undeclared
  calls throw a clear `unsafeHost.${fnName} ... was not declared`
  error; thrown host errors propagate into the sandbox as normal JS
  errors. The wrapped handler signature becomes
  `(args, ctx, actions, unsafeHost)` — fully backwards-compatible (the
  4th param is just ignored by existing handlers). SB-5.

## [1.11.0] — 2026-05-29

### Added

- **`engine.runMutations(specs, ctx)`** — new batch primitive that runs
  N mutations in a single DB transaction, fans them out as ONE live
  diff on success, and rolls every accumulated write back on any
  thrown error. No partial commits, no surprise per-mutation diffs.
  Per-mutation `authorize` still runs (inside the tx); per-mutation
  retry policies do NOT apply to batches. Empty `specs` short-circuits
  without opening a tx; unknown mutation names throw before any tx
  opens. Surfaces as a `mutationBatch` activity event.
- **`transactionalBatchAsHostTool` in `@absolutejs/sync/code-mode`** —
  pairs with `engine.runMutations`. Exposes one Code Mode host fn (by
  convention `run_transaction`) that takes an `Array<{ name, args }>`
  from the model and runs it atomically. Mutations are allow-listed at
  factory time so a hallucinated name fails fast with a clear error.
  Drop-in alongside `engineMutationsAsHostTools`; the model gets BOTH
  the individual host fns (for scripts that branch on intermediate
  results) and `run_transaction` (for atomic batches) and picks based
  on the prompt.

This closes the v0.1 cross-mutation atomicity gap the `/code-mode`
docs page called out, with no breaking changes to the v0.1 surface.

## [1.10.0] — 2026-05-28

### Added

- **New subpath `@absolutejs/sync/code-mode`** — exposes the engine's
  mutation surface as a host-tool map shape-compatible with
  `@absolutejs/ai`'s `codeModeTool({ tools })`. The factory
  `engineMutationsAsHostTools({ engine, ctx, mutations })` returns
  `Record<hostFnName, CodeModeHostTool>` with auto-derived JS-safe
  names (`'comments:create'` → `comments_create`), throws at build
  time on unregistered names or duplicate host-fn names, and threads
  a per-call `ctx()` factory through every mutation in the script.
  Tests cover the documented v0.1 partial-failure semantics: each
  `runMutation` runs in its own DB transaction, and a later throw does
  NOT roll back earlier commits. Cross-mutation atomicity is a
  deliberate v0.2 followup; this slice ships honest semantics rather
  than a transactional promise the engine can't keep without new
  primitives. SB-1 ("Code Mode as a sync primitive") groundwork.

## [1.9.2] — 2026-05-28

### Added

- **New subpath `@absolutejs/sync/testing`** — small helpers for testing
  sync engines and sync packs without each consumer redefining the same
  boilerplate. Exports:
    - `createTestEngine(options?)` — documented re-export of
      `createSyncEngine` that signals test scope at the call site. Future
      test-mode defaults (e.g. an inline transaction runner) can land
      here without churning existing tests.
    - `expectRejection(work)` — awaits `work()` and returns the thrown
      value, or throws if it resolves. Avoids Bun 1.3.x's flaky
      `expect(...).rejects.toThrow(...)` behavior
      (oven-sh/bun#31462). Equivalent to the `rejection()` helper sync's
      own tests already use locally.
    - `runAsActor(engine, actorId, mutation, args, extraCtx?)` — runs a
      mutation with `{ ...extraCtx, userId: actorId }` ctx, matching the
      standard pack convention (`getActorId: (ctx) => ctx.userId`).
      No new test framework; these are plain helpers usable with `bun:test`,
      vitest, etc.

## [1.9.1] — 2026-05-28

### Fixed

- **`@absolutejs/sync/engine` no longer eagerly evaluates Elysia at module
  load.** Previously the engine subpath barrel re-exported `syncCdc` from
  `engine/cdc.ts`, which had a top-level `import { Elysia } from 'elysia'`.
  Any consumer of `@absolutejs/sync/engine` — including sync packs that
  only use `defineCollection` / `defineSyncPack` and never touch CDC —
  had to install `elysia` in their dependency tree, or `bun test` would
  fail with `Cannot find package 'elysia'`. `engine/cdc.ts` now lazy-loads
  Elysia via `require('elysia')` on first call to `syncCdc(...)`. The
  public API is unchanged; only the load timing differs. Pack authors no
  longer need `elysia` as a devDep.

## [1.9.0] — 2026-05-28

### Added

- **Sync packs — `engine.registerPack(pack)`.** A `SyncPack` is a
  self-contained bundle of schemas, permissions, readers/writers,
  collections (view/join/graph/search/reactive), mutations, schedules,
  and CRDT field declarations. `engine.registerPack` walks the bundle and
  dispatches each entry to the matching `register*` method — no new
  persistence path, pure composition. Packs declare `ownsTables` and the
  engine rejects two packs claiming the same table with
  `PackTableConflictError`. Optional `requireDependencies: true` throws
  `PackMissingDependencyError` at register time if a `readsTables` entry
  has no reader yet. `engine.inspect().packs` surfaces registered packs
  for devtools and conflict diagnostics. See `src/engine/syncPacks.design.md`
  for the rationale, factory pattern (`create<Name>Pack(config)`), and
  composition rules ("subscribe layer, not call layer"). Pack repos live
  in the new `~/abs/sync-packs/` monorepo.
- **`ScheduleDefinition.retry: RetryPolicy`** — opt-in retry of the
  whole handler on classified-as-retryable errors. Mirrors
  `defineMutation.retry`: handler must be idempotent under retry,
  default is `isSerializationFailure`, defaults `maxAttempts: 5` /
  `maxElapsedMs: 30_000` / exponential backoff. New activity events
  `schedule` (`status: 'ok' | 'error'`) and `scheduleRetry` mirror the
  mutation activity stream.

### Exports (new on `@absolutejs/sync/engine`)

- `defineSyncPack`, `PackTableConflictError`,
  `PackMissingDependencyError`
- Types: `SyncPack`, `RegisteredPack`, `CrdtFieldsMap`

## [1.8.1] — 2026-05-28

### Changed

- **`sandboxedHandler` now uses isolated-jsc 0.8 runners.** The sync engine
  keeps the same `sandboxedHandler` API, but the implementation now builds a
  per-mutation `createIsolatedRunner()` with the `tenant-script` policy,
  precompiles the wrapped callable, and invokes it through `runner.call()`.
  Metrics records now include the resolved isolated-jsc backend when metrics
  are enabled.

### Bumped

- Optional peer dep `@absolutejs/isolated-jsc` `>= 0.6.0` → `>= 0.8.0`.
  Required for `createIsolatedRunner()`, policy presets, and runner metrics.

## [1.8.0] — 2026-05-27

### Added

- **New subpath `@absolutejs/sync/tanstack-db`** for creating TanStack DB
  collection options backed by Absolute Sync. The adapter forwards Absolute Sync
  snapshots/diffs into TanStack DB and can map TanStack insert/update/delete
  mutations back to registered Absolute Sync mutations. `@tanstack/db` is an
  optional, tightly pinned peer (`>= 0.6.7 <0.7`) because the API is still
  pre-1.0.

## [1.7.9] — 2026-05-27

### Added

- **New subpath `@absolutejs/sync/mcp` — Model Context Protocol server
  for the engine.** Surface a {@link SyncEngine}'s read + mutate
  surface to MCP-aware clients (Claude Code, Cursor, custom agents)
  through five tools:
    - `list_collections` — registered collection names + kinds + tables
    - `list_mutations` — registered mutation names
    - `inspect_engine` — full {@link EngineInspection} snapshot
    - `get_snapshot` — `{ collection, params?, ctx? }` → current rows
    - `run_mutation` — `{ mutation, args, ctx? }` → result

    ```ts
    // mcp-stdio-server.ts — point your MCP client at this file's path.
    import { createSyncMcpServer, serveStdio } from '@absolutejs/sync/mcp';
    const server = await createSyncMcpServer({
    	engine,
    	defaultCtx: { tenantId: 'demo' }
    });
    await serveStdio(server);
    ```

    Multi-tenant gating is built in: spawn one MCP server per tenant
    with `defaultCtx: { tenantId }`; the agent's per-call `ctx`
    overrides aren't required (and tools that take a `ctx` fall back
    to the server default).

    Closes the QW-5 strategy item from the May 2026 competitive dive
    (Val.town's MCP server with 36+ tools, Cloudflare's MCP exposing
    the entire Cloudflare API through "two tools in under 1,000 tokens"
    via Code Mode — sync needed to be in this conversation).

### Bumped

- New OPTIONAL peer dep `@modelcontextprotocol/sdk >= 1.29.0`.
  Install only if you import from `@absolutejs/sync/mcp`. The
  subpath loads the SDK lazily via dynamic `import()`.

## [1.7.8] — 2026-05-27

### Added

- **`bridgeFetch` — credential-brokered HTTP from inside a sandboxed
  handler.** Engine option pairs an allowlist with per-host auth
  injection. The sandbox calls `actions.fetch(url, init)`; the host
  validates the URL is in the allowlist, computes the auth header on
  the host side (so the secret never crosses into the JSC heap), runs
  `fetch`, and returns a structured-cloned response the sandbox can
  pick apart:

    ```ts
    createSyncEngine({
      bridgeFetch: {
        'api.stripe.com': {
          authorization: () => \`Bearer \${process.env.STRIPE_KEY}\`,
        },
        'api.openai.com': {
          authorization: () => \`Bearer \${process.env.OPENAI_KEY}\`,
          headers: { 'OpenAI-Beta': 'assistants=v2' },
        },
      },
    });

    // Inside any sandboxedHandler:
    const res = await actions.fetch('https://api.stripe.com/v1/customers');
    const customers = JSON.parse(res.body);
    ```

    Sandbox-supplied `Authorization` headers are stripped before the
    request is sent (so a malicious tenant can't probe whether the host
    injected an auth header by reflecting one). All other sandbox
    headers pass through. Non-allowlisted hostnames throw a clean
    "not allowlisted" error inside the sandbox before any network call.

    Closes E2B wishlist #1160's "per-sandbox credential brokering with
    selective injection" pattern, which Cloudflare Dynamic Workers
    shipped in April 2026. None of the peer sync engines have an
    equivalent (closest is Convex actions, which run with full host
    trust — no allowlist boundary).

## [1.7.7] — 2026-05-27

### Added

- **`actions.now()`** on `MutationActions`. Returns a wall-clock
  timestamp (ms since epoch) that the engine controls. Today it's
  `Date.now()`; in a future replay / rebase path the engine will pin
  it to the original call's timestamp so optimistic client and
  authoritative server runs don't silently diverge.

    Use `actions.now()` everywhere you'd reach for `Date.now()` inside
    a mutation handler. The plain `handler` form gets it as part of
    the `actions` parameter; the `sandboxedHandler` form gets it
    through the same in-VM shim as the other actions (one
    `__dispatch(callId, 'now')` host-fn call).

    Trivially additive — existing handlers using `Date.now()` keep
    working; the new primitive is opt-in.

## [1.7.6] — 2026-05-27

### Added

- **Per-call telemetry for `sandboxedHandler`.** New
  `createSyncEngine({ handlerMetrics: (record) => void })` option fires
  a `HandlerMetricsRecord` after every sandboxed-mutation invocation
  (success or failure) with:

    ```ts
    type HandlerMetricsRecord = {
    	id: string; // random per-call id
    	mutationName: string;
    	durationMs: number; // wall-clock host-side
    	cpuMs: number; // inside the JSC sandbox
    	heapBytes: number; // measured right after the script returned
    	ok: boolean;
    	errorName?: string; // present when ok === false
    	errorMessage?: string;
    	timestamp: number; // Date.now() at call end
    };
    ```

    Wire to anything: a sync collection (per-tenant dashboards), your
    observability backend, a Drizzle table for cost attribution, or
    stderr for spot-checks. The runner switches to
    `callable.callWithMetrics` when the hook is set (~0.05 ms per call
    cost — disable for hot-path mutations that don't need it). Without
    the hook, the per-call hot path is unchanged.

    Hook failures are swallowed by design: a misbehaving metrics sink
    must NOT crash the caller's mutation.

    Closes the "per-tenant observability is universally weak" gap
    surfaced by the competitive deep dive — none of the peer sync
    engines ship this primitive.

## [1.7.5] — 2026-05-27

### Changed (performance)

- **`sandboxedHandler` — install the dispatch Reference ONCE per
  isolate; route per-call via a callId argument.** 1.7.4 passed a
  fresh dispatch `Reference` as a parameter on every call, which on
  the FFI backend triggered a `JSObjectMakeFunctionWithCallback` +
  JSCallback alloc per call (~0.5 ms fixed cost). Bench regressed
  pure-handler FFI from 0.33 ms (1.7.3) → 0.96 ms (1.7.4).

    1.7.5 reverts that: install `__dispatch` ONCE per isolate as a
    global Reference closed over a per-mutation `callMap`. Each call
    generates a fresh `callId`, registers its `actions` in the map,
    invokes `callable.call([callId, args, ctx])`, and deletes the
    entry in finally. The in-VM `actions` shim closes the call id
    over `__dispatch`, so concurrent calls route to the right
    `actions` instance via their own callId — concurrent-safe by
    construction, no shared-mutable slot, no serialization queue.

    Per-call hot path: one `JSObjectCallAsFunction` + 3 cheap
    primitive packings (callId is a number; args/ctx structured-clone
    via JSON). No per-call Reference alloc.

    Expected on the bench: pure FFI back to <0.4 ms, actions FFI
    ~similar to 1.7.4 (~1.5 ms — the pump dominates there).

## [1.7.4] — 2026-05-27

### Changed (performance)

- **`sandboxedHandler` switched to `Context.compileCallable`.**
  isolated-jsc 0.6 added a `Context.compileCallable(source)` primitive:
  compile a function expression once, call it many times with different
  args. Per-call cost is one `JSObjectCallAsFunction` (FFI) or one
  postMessage (Worker) — no per-call eval, no per-call `setGlobal`.

                                  The previous 1.7.2/1.7.3 design used a shared "current actions" slot
                                  with a router Reference installed on a reused context, plus a
                                  promise queue to serialize calls into that slot. 1.7.4 throws all of
                                  that out:
                                  - Each mutation is compiled to a `Callable` once at registration.
                                    Source becomes `function(args, ctx, __dispatch) { ... return

                        userFn(args, ctx, actions); }`where`actions`is an in-VM shim

    over`\_\_dispatch`. - Per call: build a fresh dispatch `Reference`closed over this
    call's`actions`, invoke `callable.call([args, ctx, dispatch])`. - No shared slot → no serialization queue. Concurrent same-mutation
    calls are safe by construction (each has its own dispatch
    Reference closed over its own `actions`). - No reused context recycling — the callable's underlying function
    is reused; per-call work doesn't create JSC metadata that needs
    GCing.

                                    Behavioural notes: handler errors still propagate as `Error` objects
                                    with `.message` and `.name`. Timeouts still terminate the isolate
                                    on Worker; on FFI they throw `TimeoutError` and the isolate stays
                                    alive (next call respawns the context). No public API changes.

### Bumped

- Peer dep `@absolutejs/isolated-jsc` `>= 0.5.0` → `>= 0.6.0`.
  Required for `Context.compileCallable`.

## [1.7.3] — 2026-05-27

### Changed (performance)

- **`sandboxedHandler` wraps user source in a sync IIFE instead of an
  async one.** The wrapper used to be `(async () => { ... })()`, which
  always returned a Promise — forcing isolated-jsc's FFI backend to
  run setup + read evals through `unwrapResultPromise` for every call,
  even when the user's handler was sync. Switched to `(() => { ... })()`:
    - Sync user handler (returns a primitive): the IIFE returns the
      primitive directly. FFI's `unwrapResultPromise` short-circuits on
      `!JSValueIsObject` — zero extra evals, fast path.
    - Async user handler (returns a Promise): the IIFE returns the
      Promise. Unwrap pump fires normally. Same behaviour as before.

    Combined with isolated-jsc 0.5 (read+cleanup eval folded together),
    pure-handler warm dispatch on FFI is now ~1.5 ms (down from 2.47 ms
    in 1.7.2, ~4.7 ms in 1.7.1). The sync IIFE also propagates
    synchronous throws through the eval boundary directly instead of
    wrapping them in a rejection — the caller still sees an `Error`.

### Bumped

- Peer dep `@absolutejs/isolated-jsc` `>= 0.4.0` → `>= 0.5.0`. 0.5
  collapses the unwrap path's 3-eval cycle to 2 by combining the
  state read with the state-global delete.

## [1.7.2] — 2026-05-27

### Changed (performance)

- **`sandboxedHandler` warm-dispatch redesign — router Reference, reused
  context, serialized queue.** Profiling the FFI backend hot path showed
  53% of per-call time was spent installing four `actions.*` References
  (one per `setGlobal`, repeated every call), plus 8% on creating a
  fresh context per call. Refactor:
    - Install **one** `__syncAction(op, ...args)` router Reference per
      isolate at compile time (instead of four per call). The in-VM
      `actions` object is now a thin in-JS shim that dispatches through
      the router.
    - Reuse a single per-mutation context across calls; recycle every
      256 calls to bound JSC per-call metadata accumulation.
    - Serialize calls via a promise queue so the shared "current actions"
      slot stays coherent under concurrent invocations.

    Per-call hot path drops from `createContext` + 6 `setGlobal` to
    2 `setGlobal` (only the volatile `args` + `ctx`). Empirical on the
    Worker vs FFI sandbox bench (see `benchmarks/sync/RESULTS.md`):

    | Backend | warm p50 (1.7.1) | warm p50 (1.7.2) | speedup |
    | ------- | ---------------- | ---------------- | ------- |
    | worker  | 0.94 ms          | (≈ same)         | —       |
    | ffi     | 4.69 ms          | ≈ 1.5 ms         | ~3×     |

    Behavioural notes: a single mutation's sandboxed calls are now
    serialized; concurrent same-mutation invocations queue behind each
    other (they already shared one isolate, so the practical impact is
    small). Per-call context recycle is hidden from the caller. No
    public-API changes.

## [1.7.1] — 2026-05-27

### Changed

- **`sandboxedHandler` backend default flipped from `'worker'` back to
  `'auto'`.** isolated-jsc 0.4 added an async host-fn pump on the FFI
  backend (alternates Bun event-loop yields with JSC microtask drains,
  bounded by `Script.run`'s `timeout`), so the engine's `actions.*`
  async References now settle on FFI just like on Worker. `'auto'`
  picks FFI when libJSC is reachable (~300 KB cold heap, interrupt-
  driven CPU timeouts) and falls back to Worker (~46 MB cold heap,
  postMessage round-trips) otherwise. Pin to `'worker'` explicitly if
  your handler needs Web APIs (`URL`, `TextEncoder`, `WebSocket`) —
  those live in the Bun-Worker environment, not the bare JSC C API.

### Bumped

- Peer dependency `@absolutejs/isolated-jsc` from `>= 0.3.0` to
  `>= 0.4.0`. Required for the FFI async host-fn pump.

## [1.7.0] — 2026-05-27

### Changed

- **`sandboxedHandler` backend pinned to `'worker'` by default.**
  `@absolutejs/isolated-jsc` 0.2 introduced an FFI backend and changed
  its `createIsolate` default from Worker-only to `'auto'` (FFI when
  reachable). The engine's `actions.insert/update/delete/change` cross
  the sandbox boundary as **async** References, and the FFI backend
  doesn't pump async host fns (per its 0.3 documented limit). Without
  this pin, bumping `@absolutejs/isolated-jsc` to 0.3 in a downstream
  app would surface "Promise that doesn't settle synchronously" errors
  on the first `actions.*` call from a sandboxed handler. We now pass
  `backend: 'worker'` explicitly. Behavioural no-op for existing
  installs.

### Added

- **`SandboxConfig.backend: 'auto' | 'ffi' | 'worker'`** — opt into the
  FFI backend for **read-only** sandboxed handlers (ones that compute a
  derived value from `args` + `ctx` and `return` it without calling
  `actions.*`). FFI gives those a ~300 KB cold heap (vs ~46 MB on
  Worker) and interrupt-driven timeouts (the isolate survives a
  TimeoutError instead of dying). Defaults to `'worker'`.

    ```ts
    defineMutation({
    	name: 'computeRiskScore',
    	sandboxedHandler: `(args, ctx) => args.amount > ctx.dailyLimit ? 'high' : 'low'`,
    	sandbox: { backend: 'ffi', memoryLimit: 128, timeout: 1000 }
    });
    ```

### Bumped

- Peer dependency `@absolutejs/isolated-jsc` from `>= 0.0.1` to
  `>= 0.3.0`. Required for the `backend` option to exist on
  `createIsolate`; `0.3` also closes the indirect-eval residuals our
  earlier docs flagged.

## [1.6.0] — 2026-05-27

### Added

- **`engine.streamChanges({ since, signal, maxBuffer })`** — outbound CDC
  stream. Returns an `AsyncIterable<LoggedChange>` that yields historical
  log entries (where `version > since`) first, then tails live commits as
  they happen. Notify-driven (no polling): the iterator parks on a Promise
  that resolves the instant a new commit lands. Use it to feed Kafka /
  NATS / search indexers / audit pipelines / analytics warehouses from
  the engine.

    ```ts
    let cursor = lastCursorFromStorage();
    for await (const entry of engine.streamChanges({ since: cursor, signal })) {
    	await kafka.send('sync.changes', JSON.stringify(entry));
    	cursor = entry.version;
    	await persist(cursor);
    }
    ```

    - If `since` is older than the oldest entry retained in the bounded
      change log, the iterator throws `MissedChangesError` so the consumer
      notices the gap (versus silently dropping commits). Re-bootstrap
      from a fresh hydrate and resume from `availableSince`.
    - If the consumer iterates slower than the engine commits and the
      in-flight buffer overflows (`maxBuffer`, default 10000), the iterator
      throws `CdcConsumerSlowError`. Resubscribe with the last cursor.
    - Multiple concurrent streams work independently; each gets every
      entry exactly once in version order.

- **`syncCdc({ engine, path })` Elysia plugin** — exposes
  `streamChanges` as a Server-Sent Events route (defaults to
  `/sync/cdc`). Each entry becomes one SSE event with `id`, `event:
change`, and the JSON-serialized `LoggedChange` as `data`. Consumers
  resume via `?since=<version>` query param or the `Last-Event-ID`
  header that browser `EventSource` sets on reconnect. Errors
  (`MissedChangesError`, `CdcConsumerSlowError`, or anything else) come
  through as `event: error` SSE events so the client can distinguish
  them from changes.

                                                                ```ts
                                                                import { syncCdc } from '@absolutejs/sync';
                                                                new Elysia().use(syncSocket({ engine })).use(syncCdc({ engine }));
                                                                ```

                                                                New exports from `@absolutejs/sync` and `@absolutejs/sync/engine`:
                                                                `syncCdc`, `SyncCdcOptions`, `LoggedChange`, `StreamChangesOptions`,
                                                                `MissedChangesError`, `CdcConsumerSlowError`.

### Changed

- **CDC adapters: `onSkip` hook for silently-dropped events.** The
  existing CDC sources (`postgresChangeSource`,
  `mysqlBinlogChangeSource`, `createPollingChangeSource`) used to drop
  malformed payloads / unknown event types / parse-failed rows
  silently. They now accept an optional `onSkip` callback so you can
  log skips and detect oversized rows (PG `NOTIFY` truncates past
  8000 bytes), new MySQL event types, or malformed outbox rows
  before they become a "where are my changes?" mystery. Defaults to
  the previous silent behaviour.

## [1.5.0] — 2026-05-27

### Added

- **OCC retry for mutations.** `defineMutation` gains an optional
  `retry: RetryPolicy` (the type has been there since 1.3 but the loop
  is now wired). When a handler throws a classified-as-retryable error
  (default: PG `40001` / `40P01`), the engine discards the buffered
  changes, waits a backoff, and re-runs the handler in a fresh
  transaction. The number-of-attempts ceiling and the time-budget
  ceiling both apply.

    ```ts
    defineMutation({
    	name: 'transfer',
    	retry: {
    		maxAttempts: 5,
    		backoff: exponentialBackoff({ baseMs: 25, maxMs: 1_000 }),
    		isRetryable: isSerializationFailure, // default
    		maxElapsedMs: 30_000 // default
    	},
    	handler: async (args, ctx, actions) => { ... }
    });
    ```

    Each attempt builds fresh `actions` / `buffered` from `makeActions`,
    so a retry never inherits half-applied buffered changes from a
    failed attempt. Transactions reopen per attempt under
    `runInTransaction`. Handlers MUST be idempotent under retry —
    external side effects (HTTP, email) will fire more than once.

    On exhaustion the engine throws a `RetriesExhaustedError` whose
    `.cause` is the underlying error and whose `.attempts` /
    `.elapsedMs` describe the run. A non-retryable first-attempt
    failure passes through with its original error preserved, even if
    `retry` is configured.

    New exports from `@absolutejs/sync/engine`: `RetryPolicy`,
    `exponentialBackoff`, `isSerializationFailure`,
    `RetriesExhaustedError`, `ExponentialBackoffOptions`.

- **`mutationRetry` engine activity event.** Between attempts the
  engine emits a new event shape on `onActivity(...)` so dashboards
  and observability sinks can see retries happen:

    ```ts
    {
    	type: 'mutationRetry',
    	at: number,
    	name: string,
    	attempt: number, // the attempt that just failed (1-indexed)
    	delayMs: number,
    	errorName: string,
    	errorMessage: string,
    }
    ```

    The final `mutation` event (`status: 'ok'` or `'error'`) still fires
    exactly once per call.

## [1.4.0] — 2026-05-27

### Added

- **Sandboxed mutation handlers.** `defineMutation` now accepts a
  `sandboxedHandler: string` (mutually exclusive with `handler`) that runs
  inside an [`@absolutejs/isolated-jsc`](https://github.com/absolutejs/isolated-jsc)
  Isolate — a separate JavaScriptCore VM with its own heap. Per-mutation
  `sandbox: { memoryLimit, timeout }` caps CPU/memory. Use for
  multi-tenant PaaS handlers, plugin systems, AI-generated code, or as
  defense-in-depth on first-party logic.

    ```ts
    defineMutation({
    	name: 'transfer',
    	sandbox: { memoryLimit: 32, timeout: 1000 },
    	sandboxedHandler: `async (args, ctx, actions) => {
    		// Runs in a fresh JSC heap. Only args, ctx, and actions are reachable.
    		await actions.update('accounts', { id: args.from, balance: ... });
    		await actions.update('accounts', { id: args.to, balance: ... });
    	}`
    });
    ```

    First call per mutation pays a Worker spawn + compile (~30 ms); every
    subsequent call reuses the isolate (~0.5 ms cold-context spin-up). Timeout
    terminates the isolate; the next call transparently re-spawns.
    `@absolutejs/isolated-jsc` is an **optional** peer dependency — install
    only if you use `sandboxedHandler`.

- **Registration validation.** `registerMutation` now throws if a
  definition has neither `handler` nor `sandboxedHandler`, or if it has
  both. (Previously the missing-handler case crashed at first invocation
  with a less helpful error.)

## [1.3.0] — 2026-05-27

### Added

- **Cross-client reactive query cache.** Subscriptions sharing the same
  `(collection, params, ctx)` now reuse a cached snapshot on initial
  subscribe instead of each re-running the query body. 1.1 deduped reruns
  within a single write batch; 1.3 lifts that sharing _across_ batches.
  Behaviour, in one line: with N fresh subscribers to the same query, the
  query body runs **once** at the first subscribe; subscribers 2…N hit
  the cache. An overlapping write invalidates the entry (same
  `isReactiveAffected` check live subs already use), and the rerun fired
  by that write refreshes the cache so the next subscriber is a hit
  again.

    Configurable via the new `reactiveCache` option on `createSyncEngine`:

    ```ts
    createSyncEngine({
    	reactiveCache: {
    		max: 256, // LRU bound (default 256). 0 disables the cache.
    		ttlMs: 60_000 // TTL (default 60s). 0 disables the TTL.
    	}
    });
    ```

    Defaults are bounded by design — no engine should leak memory on a
    query that's never re-subscribed. Different `ctx` references stay
    isolated (per-user query bodies are unaffected).

    This is the same pattern Convex uses to coalesce queries across all
    online clients ("every specific combination of (query code, parameters,
    database read set) executes only once"). Sync's read-set tracking +
    stable sub-key were already there; this PR just lifts the existing
    per-batch `sharedRuns` map to a persistent one with invalidation +
    bounded eviction.

    4 new tests in `tests/reactiveQuery.test.ts`: cache hit on second
    subscribe, invalidation on overlapping write + refresh on the rerun,
    `max: 0` disables, different ctxs miss independently.

## [1.2.0] — 2026-05-27

### Added

- **`disconnect()` on client + collection.** Force-close the underlying
  WebSocket _without_ tearing down state. The auto-reconnect loop fires
  after `reconnectMs`, each entry's `appliedVersion` is preserved, and the
  resumed subscribe carries `since` so the engine replies with a catch-up
  diff (or a fresh snapshot if the change log no longer covers the gap).

    This exposes the existing resume-via-`since` path (already shipped, see
    `engine.subscribe`'s `since` parameter + the change-log + the catch-up
    diff builder) so tests, benches, and apps can simulate an offline blip
    cleanly. Pairs with the auto-reconnect loop that's been in place since
    the WebSocket client landed.

    ```ts
    const tasks = createSyncCollection<Task>({ collection: 'tasks', url });
    // …client has appliedVersion = N…
    tasks.disconnect(); // closes the WS without losing state
    // …server applies M more changes while we're "offline"…
    // auto-reconnect fires, subscribe carries since: N,
    // engine replies with a catch-up diff covering (N, N+M]
    ```

    No behavioural change for clients that don't call `disconnect()`. The
    existing `close()` semantics (tear down everything, stop reconnecting)
    are unchanged.

## [1.1.0] — 2026-05-27

### Changed

- **Reactive subscription fan-out is no longer O(N) in subscribers.** The
  engine now memoises each reactive query's rerun per change batch, keyed by
  `(collection, params, ctx)`. Subscribers sharing equivalent keys (e.g.
  many tabs of the same view, many clients of the same anonymous query)
  share a single rerun of the query body instead of each triggering their
  own. Each subscription still diffs the shared result against its own
  current state and receives its own per-sub frame.

    Measured against the existing reactive-read bench (one writer mutates,
    N subscribers receive — slowest-tail latency per write):

    | subscribers | tail p50 before (1.0) | tail p50 after (1.1) | speedup   |
    | ----------- | --------------------- | -------------------- | --------- |
    | 1           | 7.3 ms                | 11.3 ms              | ~same     |
    | 10          | 28.2 ms               | 12.5 ms              | 2.3×      |
    | 100         | 161.4 ms              | 27.6 ms              | **5.9×**  |
    | 1,000       | 1,645.3 ms            | **81.2 ms**          | **20.3×** |

    At 1,000 subscribers the tail dropped from ~1.6 s to ~80 ms; p99 from
    ~2,650 ms to ~93 ms (28×). The cost shape changed from linear O(N) to
    near-constant in the number of subscribers — what's left is per-WS frame
    write, the focus of the next pass.

    Correctness: subscribers with different `ctx` references still get
    independent reruns (a per-user query body can depend on `ctx.userId`).
    The dedup key uses stable JSON when possible and falls back to per-object
    identity for values JSON can't represent, so an exotic `ctx` never silently
    shares results with a different one.

## [1.0.0] — 2026-05-26

API freeze. The package has been in production-quality shape across the recent
minor releases; 1.0 declares the surface stable.

### Added (cumulative since 0.10)

- **`/crdt` — conflict-free collaborative editing.** Zero-dependency, isomorphic
  CRDT kit (PN-counter, LWW register, an RGA collaborative-text type), plus a
  pluggable `TextCrdtAdapter<State>` contract with `rgaText` as the first-party
  backend. Third-party backends (Yjs, Automerge, Loro) live in the
  [`sync-adapters`](https://github.com/absolutejs/sync-adapters) monorepo and
  drop in behind the same hook (0.10).
- **Declarative CRDT primitive.** `engine.registerCrdt(table, { field: rgaText })`
  auto-merges declared CRDT fields on `actions.insert/update` and auto-registers
  a `"<table>:merge"` upsert mutation. A `createCollaborativeText` controller and
  `useCollaborativeText` / `createCollaborativeTextStore` /
  `SyncCollectionService.collaborativeText` bindings (React, Vue, Svelte,
  Angular) wrap it (0.11).
- **Delta uploads.** `createTextCrdt` gains `takeDelta()` (returns just this
  client's new ops); the controller uploads deltas — O(edit), not O(doc) per
  keystroke. Server keeps full state for trivial late-joiner hydration. Benched
  at **84×–8,350×** smaller than full-state at 100–10,000 chars (0.12).
- **Tombstone compaction.** `compact(state)` drops tombstones no live element
  anchors to (visible text unchanged); `tombstoneCount(state)` is the metric.
  `linearize` re-roots orphans deterministically, so a stale client briefly
  referencing a compacted tombstone never loses content (0.13).
- **More CRDT types.** `orSet` (observed-remove, add-wins), `lwwMap` (per-key
  LWW with delete tombstones), `createList` (ordered-list RGA over arbitrary
  items, with delta support) (0.14).
- **Collaborative cursors.** `anchorAt(index)` / `indexOfAnchor(anchor)` on the
  text CRDT — caret survives concurrent edits; passthrough on the controller and
  every framework hook (0.15).

### Architectural baseline (from earlier releases, in shipped state)

- Reactive push (`createReactiveHub`, `sync` plugin), ORM-derived topics
  (Drizzle, Prisma), `createLiveQuery`, and a write-behind cache.
- Sync engine (Tier 3): row-level diffs over a WebSocket, optimistic mutations,
  offline queue, local-first IndexedDB cache, declarative permissions, schema
  validation + lazy migrations, live full-text + vector search, scheduled
  functions, a live devtools dashboard, CDC for Postgres/MySQL/SQLite,
  incremental aggregations + joins, and a declarative operator graph.
- Framework bindings as subpaths: `/react`, `/vue`, `/svelte`, `/angular`,
  `/client`, `/engine`, `/crdt`, `/scheduled`, `/drizzle`, `/prisma`,
  `/postgres`, `/mysql`, `/sqlite`.

### Compatibility

- Public APIs across `.`, `/client`, `/engine`, `/crdt`, `/scheduled`, the four
  framework bindings, and the DB/ORM adapter subpaths are stable as of 1.0.
- All listed peers (`elysia`, `drizzle-orm`, `@elysiajs/cron`, framework
  packages) remain optional.
- Adapters (`@absolutejs/sync-yjs`, `-automerge`, `-loro`) version
  independently and target `@absolutejs/sync >= 0.10`; they are unchanged by
  1.0.

## Earlier releases

The 0.x line evolved the engine, framework bindings, CDC adapters, search,
scheduled functions, devtools, permissions, schema/migrations, and the CRDT
story above. Git history is the source of truth; this changelog starts tracking
formally at 1.0.
