# @warmhub/sdk-ts changelog

<!-- warmhub-changelog-artifact:v1 -->

## 0.151.0

No new release notes.

## 0.150.0

No new release notes.

## 0.149.0

No new release notes.

## 0.148.0

No new release notes.

## 0.147.0

No new release notes.

## 0.146.0

No new release notes.

## 0.145.0

No new release notes.

## 0.144.0

No new release notes.

## 0.143.0

No new release notes.

## 0.142.0

No new release notes.

## 0.141.0

No new release notes.

## 0.140.0

### Changed

A resumed repository export now sends the `formatVersion` of the header the download opened with, and the server refuses a resume whose format is not the one it writes: HTTP 412 `client-incompatible` with the message "Restart the export; a resume must use the format it started with." A download started before a server upgrade that changes the export format can no longer be silently finished under its old header; the resume fails and the export must be restarted.

A resume of a file that holds only the header (interrupted before the first row) sends no cursor, so the server cannot check it; the session now compares the new header's format to the saved one and raises `RepositoryExportError` (`header_invalid`) with the same restart message rather than appending new-format rows under the old header.

**Upgrade with the server.** An older SDK sends no `formatVersion` on a resume, so a server with this change refuses every resume from it, not only cross-format ones. Upgrade the SDK in the same release as the server.

### Added

`isAllStreamOperationsFailedError(error)` reports whether a thrown value is an all-failed stream error. Unlike `error instanceof AllStreamOperationsFailedError`, it also recognizes the error after `toWarmHubError` normalization and when a different copy of the SDK threw it.

### Breaking

#### `NAME_TAKEN` names the holder by durable id only and offers no replacement name

**What it was.** A `name_taken` error's `details.takenBy` was `{ shape, durableId }`, `details.suggestedName` could carry a replacement name, and the message said `by a <Shape> Thing` and `for example "<name>"`.

**What it is now.** `details.takenBy` is `{ durableId }`; `shape` is removed. `details.suggestedName` is removed and no example name appears in the message or hint. The message names no Shape: `Name "acme" is already taken in this repository by another Thing; choose another name`. A caller who cannot read the holder still gets no `takenBy` and no `by another Thing`. The `name_taken` decoder in the streaming submission protocol requires only `takenBy.durableId`.

**Why it breaks.** This is a client-visible breaking change, accepted. Released sdk-ts 0.135.0 to 0.139.0 decode `takenBy` with `shape` required, so they refuse a `name_taken` result from a server that carries this change. It lands before the v2 floor release (0.140.0), so no v2 client sees `shape`.

**Migration.** Read the holder's Shapes with `get` on `details.takenBy.durableId`; a Thing can have several Shapes or none. Choose the replacement name yourself.

```ts
// Before
const { takenBy, suggestedName } = details
console.log(takenBy?.shape, suggestedName)

// After
const holder = details.takenBy && (await client.thing.get(org, repo, details.takenBy.durableId))
```

### Added

The `restore` operation and `OperationBuilder.restore()` make a retracted Thing active again, by its durable ID. Pass `newName` to restore it under another name.

In these notes, "old grammar" means the reference form used before this release (`Deal/acme`, operations with `kind`), and "new grammar" the form this release introduces (`acme`, operations with `shapes`).

### Breaking

#### Write operations take `name` and `shapes`

**What it was.** Operations carried `kind`, an add name spelled
`Shape/name`, a top-level `about`, or collection `type`/`members`, and the
SDK converted them.

**What it is now.** `Operation`, `AddOperation`, `ReviseOperation`,
`RetractOperation`, `ReaffirmOperation` and `RenameOperation` keep their
names but have the new shape. An add or revise requires `name`, `shapes`
and `data`. `kind` and `shape` are typed `never`. The new `WriteOperation`
type is one operation of that form.

- A Shape is the Thing `hub/shapes/X` (`shapeName('X')`), written with
  `shapes: []`.
- An assertion is a Thing one of whose declared Shapes composes `Assertion`,
  with its target in `data.about`.
- A collection is a Thing of its collection Shape:
  `{ shapes: ['Set'], data: { members } }`.

**Migration.**

```ts
// Before
await client.commit.apply('acme', 'world', 'seed', [
  { operation: 'add', kind: 'thing', name: 'Deal/acme', data: { company: 'Acme' } },
])

// After
await client.commit.apply('acme', 'world', 'seed', [
  { operation: 'add', name: 'acme', shapes: ['Deal'], data: { company: 'Acme' } },
])
```

#### Old-grammar operations are refused before any request

**What it was.** The SDK converted old-grammar operations.

**What it is now.** An operation with `kind`, `shape`, `wref`,
`declaredShapes`, `about`, collection `type` or `members`, or with no
`operation`, is refused with a `WriteOperationError` before anything is
sent. The message shows a suggested new form, with data values replaced by
`"..."`. Names and `about` targets are copied as written, so check them: a
suggested `name: 'Deal/acme'` would address a Thing literally named
`Deal/acme`. An add or revise with no `shapes` is refused with a message
that it states no Shapes.

Old-grammar input no longer type-checks, so it reaches this refusal only
through a cast.

**Migration.**

```ts
// Before: converted and sent
await client.commit.apply('acme', 'world', 'rate', [
  { operation: 'add', kind: 'assertion', name: 'Rating/r1', about: 'Deal/acme', data: { score: 5 } },
])

// After
await client.commit.apply('acme', 'world', 'rate', [
  { operation: 'add', name: 'r1', shapes: ['Rating'], data: { about: 'acme', score: 5 } },
])
```

Other operations refused locally:

- a pinned Shape in `shapes` (`Deal@v2`), or an entry that is not a bare
  Shape name (`hub/shapes/Deal`, anything with `/`);
- `shapeless` on a raw operation (spell it `shapes: []`);
- non-empty `shapes` on a `hub/shapes/X` name;
- an add or revise without `data`, and `keepShapes` on an add;
- `affirmedTargets` on a shapeless write;
- `expectedVersion` on an add, and `active` on a revise;
- renaming a Shape to a non-Shape name, or the reverse;
- `+` in an added or renamed-to name;
- an added or renamed-to name under the reserved `hub` root
  (`RESERVED_NAME`);
- the same name added twice in one submission (`ILLEGAL_OP_SEQUENCE`);
- errors found by the local Shape-definition checks.

#### `OperationBuilder` methods take the name first

**What it was.** `add({ name, data })`, `revise({ name, data })`,
`retract(target)`, `reaffirm({ name, kind, ... })`; no `rename`.

**What it is now.**

| Method | After |
|---|---|
| `add` | `add(name, { shapes \| shapeless, data, ... })` |
| `revise` | `revise(name, { shapes \| shapeless \| keepShapes, data, ... })` |
| `retract` | `retract(name, { reason? })` |
| `reaffirm` | `reaffirm(name, { add?, remove? })` |
| `rename` | `rename(name, newName)` (new) |

Each add and revise states its Shapes in exactly one way: `shapes: [...]`,
`shapeless: true`, or (revise only) `keepShapes: true`. The builder refuses
zero ways or more than one, `keepShapes` on an add, `shapeless` on a
`hub/shapes/X` name, and `shapes: []` on a non-Shape name (spell that
`shapeless: true`).

**Migration.**

```ts
// Before
import { OperationBuilder } from '@warmhub/sdk-ts'
const ob = new OperationBuilder()
ob.add({ name: 'Deal/acme', data: { company: 'Acme' } })
ob.retract('Deal/old')
await ob.commit({ client, orgName: 'acme', repoName: 'world', message: 'seed' })

// After
import { createOperationEventRequestId } from '@warmhub/sdk-ts'

await client.shape.create('acme', 'world', 'Deal', { company: 'string' }, {
  eventRequestId: createOperationEventRequestId(),
})

await client.commit.apply(
  'acme',
  'world',
  'seed',
  client
    .ops()
    .add('acme', { shapes: ['Deal'], data: { company: 'Acme' } })
    .add('scratch', { shapeless: true, data: { note: 'free' } })
    .rename('scratch', 'scratch-2')
    .retract('old'),
)

// A later submission: keepShapes revises a Thing that already exists
await client.commit.apply(
  'acme',
  'world',
  'update',
  client.ops().revise('acme', { keepShapes: true, data: { company: 'Acme 2' } }),
)
```

A `keepShapes` revise of a Thing added or renamed earlier in the same
submission is refused; state `shapes` instead.

#### Builder errors are `WriteOperationError`, raised when an operation is queued

**What it was.** Some refusals surfaced only at commit.

**What it is now.** A per-operation refusal throws at the `.add(...)` or
`.revise(...)` call. Whole-batch refusals ("already submitted", "in flight")
have `operationIndex: undefined`. The code is usually `VALIDATION_ERROR`;
it can also be `RESERVED_NAME`, `ILLEGAL_OP_SEQUENCE`, a Shape-name check
code, or (for `keepShapes`, at submit) `NOT_FOUND`.

**Migration.**

```ts
import { WriteOperationError, type AddInput } from '@warmhub/sdk-ts'

try {
  client.ops().add('acme', { data: {} } as AddInput) // no Shapes stated
} catch (e) {
  if (e instanceof WriteOperationError) console.log(e.code, e.operationIndex) // VALIDATION_ERROR 0
}
```

#### Every reference argument uses the new grammar

**What it was.** Read and write calls took `Deal/acme`, and a Shape was
`Deal`.

**What it is now.** Pass the Thing name (`acme`) and `hub/shapes/Deal` for a
Shape where any Thing can appear. An old spelling is looked up literally: a
single read gets `NOT_FOUND`, and `thing.getMany` lists it in `missing`.
Globs (`match`) match Thing names, and `*` does not cross `/`.

**Migration.**

```ts
// Before
await client.thing.get('acme', 'world', 'Deal/acme')
// After
await client.thing.get('acme', 'world', 'acme')
```

#### `thing.rename` takes full names

**What it was.** `rename(org, repo, shapeName, oldName, newName, opts)`.

**What it is now.** `rename(org, repo, name, newName, opts)`. A call in the
old argument order is refused locally with `VALIDATION_ERROR`.

**Migration.**

```ts
// Before
await client.thing.rename('acme', 'world', 'Deal', 'acme', 'acme-corp', { eventRequestId })
// After
await client.thing.rename('acme', 'world', 'acme', 'acme-corp', { eventRequestId })
```

#### Read results drop `shape`, `shapeName` and `validatedShape`

**What it was.** Results carried a single Shape.

**What it is now.** Use `declaredShapes` (the Shapes the version states)
and `validatedShapes` (the Shapes it satisfies, including composed ones).
Both hold version-pinned names such as `Deal@v3`. The removal covers
`ThingDetail`, `ThingItem`, `thing.getMany` items, `thing.getWithLease`,
history versions and history's `thing`, refs items, component owned Things
and `view.evaluate` items. `SynthesizedRepoContent.shape` becomes
`declaredShapes` / `validatedShapes`.

`ThingDetail` allows extra keys, so `detail.shapeName` still compiles; it is
`undefined` at run time. Search your code for these field names.

`shape` as an input filter (`thing.head(org, repo, { shape: 'Deal' })`) is
unchanged.

**Migration.**

```ts
// Before
const shape = detail.shapeName
// After
const shapes = (detail.declaredShapes ?? []).map((w) => w.replace(/@v\d+$/, ''))
```

#### Token scopes use `grants`, on input and output

**What it was.** A scope entry carried `allowedMatches` and `allowedShapes`.

**What it is now.** Restrictions are a list of (paths, Shapes) pairs in
`grants`.

- Input (`token.create`): the entry-level fields are still typed `unknown`,
  so old code compiles, but the server refuses them with "allowedMatches and
  allowedShapes are no longer scope-entry fields: give each (paths, Shapes)
  pair in grants…".
- Output (`TokenCreateResult`, token metadata, whoami scopes): the
  entry-level fields are removed, and reading them is a compile error. Read
  `grants`.
- `org.setMemberScopes` takes entries with `resource` and `permissions`
  only; restrictions on member scopes are refused.
- A pair must carry a non-empty `allowedMatches`, or an `allowedShapes`
  with at least one key. `grants: []`, `{}` and `{ allowedShapes: {} }` are
  refused.
- `shapeless: true` in a clause is not a restriction of its own: it lets
  Things with no Shape through. Alone it admits every Thing the pair's paths
  match, shaped or shapeless; beside `shapes` it adds shapeless Things to
  the Things the clause covers. No clause restricts a pair to shapeless
  Things only.

**Migration.**

```ts
// Before
await client.token.create({ name: 'ci', scopes: [
  { resource: 'acme/world', permissions: ['read'], allowedMatches: ['Deal/**'] },
] })
// After
await client.token.create({ name: 'ci', scopes: [
  { resource: 'acme/world', permissions: ['read'],
    grants: [{ allowedMatches: ['**'], allowedShapes: { shapes: ['Deal'] } }] },
] })
```

#### Repository exports are format 6, and the delta fold needs formats

**What it was.** Exports were format 5, and
`applyRepositoryExportDelta(base, delta)` returned rows keyed by durable id.

**What it is now.**

- The server writes format 6. This SDK reads 5 and 6; older SDKs read only
  5, so they cannot read exports made after this release reaches
  production.
- Format 6 uses new-grammar references, has one row per Shape version, and
  may carry `retracted: true` on Shape rows. A Shape tombstone in format 6
  is rejected as `row_invalid`.
- `applyRepositoryExportDelta` takes a third argument, the formats. Mixing
  format 5 and format 6 throws `RepositoryExportError` with reason
  `format_mismatch`.
- In the returned map, format 6 Shape rows are keyed `durableId@vN`, not
  `durableId`. Code that looks a Shape up by durable id, or keys its own map
  by durable id, must account for versions.

**Migration.**

```ts
// Before
const current = applyRepositoryExportDelta(base, delta)
// After
const current = applyRepositoryExportDelta(base, delta, {
  base: baseSession.header!.formatVersion,
  delta: deltaSession.header!.formatVersion,
})
```

#### `stream.append` takes new-grammar operations only

**What it was.** `stream.append` took the old operation form.

**What it is now.** It takes new-grammar operations and does not accept
`keepShapes` (use `createKeepShapesResolver`). Its only local check is a
pinned Shape; everything else is checked by the server.

**Migration.** Send `{ operation, name, shapes, data }` operations.

#### Writes need a server running this release

**What it was.** The SDK wrote to any current server.

**What it is now.** Against an older server, writes fail the compatibility
check with "@warmhub/sdk-ts requires write contract 3, but the backend
provides 2."

**Migration.** Upgrade the SDK after the server.

### Added

- **`client.ops(options?)`** — returns a new `OperationBuilder`.
- **`shapeName(bare)`** — `'Deal'` to `'hub/shapes/Deal'`; idempotent.
- **`isShapeReference(value)`** — true for a bare, unpinned Shape name.
- **`WriteOperationError`** (extends `WarmHubError`) — with
  `operationIndex`; its message starts `Invalid operation at index N:`.
- **Types** — `WriteOperation`, `KeepShapesRevise`, `AddInput`,
  `ReviseInput`, `RetractInput`, `ReaffirmInput`, `ShapesChoice`,
  `CommitValidateOperations`, `RepositoryExportDeltaFormats`,
  `ThingShapesReader`.
- **`keepShapes: true` on a revise** — at submit the SDK reads the Thing's
  current Shapes and version and sends both, the version as
  `expectedVersion` (a supplied `expectedVersion` wins). Shapes are sent
  bare, so the revise is checked against each Shape's current version. A
  missing Thing is refused with `NOT_FOUND`. A Thing added, or renamed to or
  from, earlier in the same submission is refused. A Thing revised earlier in
  the same submission reuses that revise's Shapes and sends no version.
  Because the version is pinned, resubmitting the same `submissionId` from
  another process can conflict; explicit `shapes` is the retry-safe form.
  ```ts
  await client.commit.apply('acme', 'world', 'm',
    client.ops().revise('acme', { keepShapes: true, data: { company: 'Acme 2' } }))
  ```
- **`createKeepShapesResolver(read)`** — resolves `keepShapes` revises for
  `stream.append`. It keeps state across calls, so use one resolver per
  submission.
  ```ts
  const resolve = createKeepShapesResolver((names) => client.thing.getMany('acme', 'world', names))
  await client.stream.append({ /* ... */ operations: await resolve([
    { operation: 'revise', name: 'acme', keepShapes: true, data: {} },
  ]) })
  ```
- **Builders everywhere** — `commit.validate`, `commit.apply` and
  `commit.applyStreaming` accept an `OperationBuilder` as well as an array.
- **`shapeless: true` read filter** — on `thing.head`, `thing.query`,
  `thing.count` and `live.thingHead`: only Things with no Shape. It
  cannot be combined with `shape`, `declaredShape`, `match`, a token
  restricted by paths, or `sinceRepoSeq`, and is not available on search or
  the changes feeds.
  ```ts
  await client.thing.head('acme', 'world', { shapeless: true })
  ```
- **`warnings.shapeless?: true`** — on per-operation write results.
- **`ThingGetManyResult.missingHints`** — for a missing reference that is an
  old `Shape/name` spelling of a Thing you can read, the text naming its new
  form.
- **`declaredShapes` on refs items and history's `thing`** (history also
  gains `validatedShapes`).
- **`redactedResource: true`** — may appear on `TokenCreateResult` scopes.
- **`details.reason` values** — `'legacy-wrefs-window-ended'` (from the
  server) and `'legacy-wrefs-sdk'` (local).
- **`DEPENDENCY_FAILED`** — exported as a constant.
- **`LEGACY_WREFS_REFUSAL` and `WarmHubClient.clientFlags`**.
- **Export** — `RepositoryExportErrorReason` gains `'format_mismatch'`;
  `RepositoryExportSession.lastShapeVersion`; an `onRow` option on
  `restoreRepositoryExportSession`. A resume that breaks between two versions
  of one Shape continues from the right version.

### Behavior worth knowing

- **`clientFlags: ['legacy-wrefs']` refuses every call.** The SDK does not
  send old-grammar requests. With the flag set, reads, writes, streaming,
  export and the compatibility check all throw `WarmHubError` with code
  `CLIENT_INCOMPATIBLE`, `details.reason: 'legacy-wrefs-sdk'`, and the
  message "`legacy-wrefs` is set; the SDKs are v2-only. Unset it, or use the
  `wh` CLI for v1." Use the CLI to submit old-grammar files during the
  compatibility window.

### Changed

- **Local checks before sending.** `commit.apply`, `commit.validate` and
  the builder check every operation before sending when given an array or a
  builder. An iterable, an async iterable, or `commit.applyStreaming` is
  checked chunk by chunk, so a bad operation late in the source is refused
  after earlier chunks were committed (`PartialStreamSubmissionError`).
  `stream.append` checks only pinned Shapes.
- **Content-limit error labels.**
  ```text
  Before: Field "Content/Readme.content" is N bytes; WarmHub content fields are limited to 65536 bytes. ...
  After:  Field "Readme.content" is N bytes; WarmHub content fields are limited to 65536 bytes. ...
  ```
  `Agents.content` changes the same way.

### Removed

- **`AddOp`, `ReviseOp`, `RetractOp`, `CollectionAddOp`,
  `CollectionAddType`, `OperationBuilderAddInput`** — use `WriteOperation`
  and the builder input types.
  ```ts
  // Before
  const op: AddOp = { name: 'Deal/acme', data: {} }
  // After
  const op: WriteOperation = { operation: 'add', name: 'acme', shapes: ['Deal'], data: {} }
  ```
- **Automatic old-grammar conversion** (`kind`, `about`, `type`/`members`,
  `Shape/name` splitting).
- **The local "Selector-backed revise requires a Set/<name> target wref"
  check in `collection.revise`.** The server decides.

## 0.139.0

No new release notes.

## 0.138.0

No new release notes.

## 0.137.1

No new release notes.

## 0.137.0

No new release notes.

## 0.136.0

No new release notes.

## 0.135.0

No new release notes.

## 0.134.0

No new release notes.

## 0.133.0

No new release notes.

## 0.132.0

No new release notes.

## 0.131.0

No new release notes.

## 0.130.2

No new release notes.

## 0.130.1

No new release notes.

## 0.130.0

No new release notes.

## 0.129.1

No new release notes.

## 0.129.0

No new release notes.

## 0.128.0

### Documentation

Versioned release notes are available as [HTML, Markdown, and JSON](https://docs.warmhub.ai/sdk/typescript/changelog/).

## 0.127.0

### Release changes

No SDK source changes.

Reconstructed from SDK release tags.

## 0.126.0

### Release changes

- feat(collections): Arc and Bond become ordinary Things under protected V2 Shapes (commit `50fec9ce2a8f`)
- feat(collections): the Collections V2 cutover with a legacy-sugar window (commit `adaaa4fe53dc`)
- feat(collections): split the read kind and key collection-ness on the certificate (commit `6a33c1713c45`)
- feat(collections): classify inbound traversal by closure and add the aggregate roles (commit `ca07faa123f0`)
- feat(collections): carry the collections summary across every read surface (commit `8147aff4dfc5`)
- fix(collections): let a legacy collection row be retracted (GH-10975) (commit `9b625cb9c67c`)
- test(collections): invert the tests the ruling slice moves (commit `79a1d08eb82d`)
- fix(collections): stop head and history claiming member facts they cannot see (commit `9c6752da5e8d`)
- feat(collections): put the member layout on the Shape and the facts on the row (commit `be4d60df9499`)
- test(collections): pin the layout ruling and the four review findings it touches (commit `102b6e20d7a2`)
- feat(collections)!: define member position within a field, and nowhere else (commit `d4d69aaf2282`)
- feat(export)!: carry Shape certificates as pinned wref strings (commit `30187cb8082e`)
- fix(rules): model the v3 collection row and close the pinned-wref newline hole (commit `dd2dc046d7da`)
- fix(collections)!: name a foreign certifying Shape by its repository (commit `18478e45b47f`)

Reconstructed from SDK release tags.

## 0.125.0

### Release changes

No SDK source changes.

Reconstructed from SDK release tags.

## 0.124.0

### Release changes

- chore(compat): #10974 retire transitional client contracts and startup adoption (commit `4347a0500db6`)

Reconstructed from SDK release tags.

## 0.123.0

### Release changes

- fix(component): bound manifest regex evaluation (#10870) (commit `03a9129692b1`)
- fix(rules): validate manifest commit filters (#10884) (commit `a60d060c9139`)
- fix(rules): validate folded array field names (#10886) (commit `efeb4938b9b6`)

Reconstructed from SDK release tags.

## 0.122.3

### Release changes

- test(backend): reduce avoidable test isolation (commit `ca288390db56`)
- perf(query): A1 — bound every typed count arm and report the bound (commit `cc93a4636a8b`)

Reconstructed from SDK release tags.

---

Historical changelog shipped with @warmhub/sdk-ts 0.120.0:

# Changelog — `@warmhub/sdk-ts`

## 0.120.0

Repository export v3.

### Breaking

#### Checkpoint generation is retired — take an export instead

**What it was.** Producing a fresh snapshot of a repository meant asking the
server to mint a checkpoint, polling until the job completed, requesting a
short-lived signed URL for the archive, downloading it outside the SDK, and
verifying the bytes locally.

**What it is now.** One call that streams verified rows, with the header,
per-row canonical decode, ordering and trailer checks applied as the bytes
arrive. There is no job to start, no state to poll, and no separate verify
step — a row that reaches you has already been proven.

**Migration.**

Before:

```ts
import { createReadStream } from 'node:fs'
import { writeFile } from 'node:fs/promises'
import { Readable } from 'node:stream'
import { verifyRepositoryCheckpointArchive } from '@warmhub/sdk-ts/checkpoint'

let status = await client.repo.checkpoint.generate('acme', 'catalog')
while (status.state !== 'complete') {
  await new Promise((resolve) => setTimeout(resolve, 1_000))
  status = await client.repo.checkpoint.status('acme', 'catalog', {
    checkpointId: status.checkpointId,
  })
}

const access = await client.repo.checkpoint.getAccess('acme', 'catalog', {
  checkpoint: 'latest',
  artifact: 'archive',
})
// Signed URL: fetched WITHOUT the WarmHub bearer token.
const archive = await fetch(access.url)
await writeFile('catalog.zip', Readable.fromWeb(archive.body))
await verifyRepositoryCheckpointArchive(createReadStream('catalog.zip'))
```

After:

```ts
for await (const row of client.repo.export('acme', 'catalog')) {
  console.log(row.kind, row.durableId, row.version)
}
```

If you were relying on `generate` returning before the download — starting the
build in one process and fetching it in another, or on another machine — that
shape survives as the async token flow:

```ts
// Process A: ask for it, get a token, do not read a byte.
const prepared = await client.repo.exportPrepare('acme', 'catalog')
console.log(prepared.exportToken, prepared.atRepoSeq)

// Process B: redeem it. `export` polls while the fold is still running.
for await (const row of client.repo.export('acme', 'catalog', {
  token: prepared.exportToken,
})) {
  // ...
}
```

The token is redeemable only at that repository's URL, by a principal holding
checkpoint read there.

**Why.** Export format v3 replaces checkpoint generation outright; the whole
generation pipeline is deleted server-side (PR #10020).

#### `client.repo.checkpoint.generate` and `.retry` are gone

**What it was.** `generate(orgName, repoName, { atLeastRepoSeq })` minted a
checkpoint; `retry(orgName, repoName, checkpointId)` re-ran a failed one. Both
returned a `RepositoryCheckpointStatus`.

**What it is now.** Neither method exists, and the tRPC procedures behind them
(`repo.checkpoint.generate`, `repo.checkpoint.retry`) are no longer served. The
`repo:checkpoint-generate` scope no longer buys anything.

**Migration.** Replace both with `client.repo.export`.

Before:

```ts
const fresh = await client.repo.checkpoint.generate('acme', 'catalog', {
  atLeastRepoSeq: 42,
})
const recovered = await client.repo.checkpoint.retry(
  'acme',
  'catalog',
  failed.checkpointId,
)
```

After:

```ts
// `atRepoSeq` pins the fence the way `atLeastRepoSeq` asked for a floor.
// Omit it and the server pins current and echoes it back in the header.
for await (const row of client.repo.export('acme', 'catalog', {
  atRepoSeq: 42,
})) {
  // ...
}
```

There is no retry to replace: an export is a read, so a failed one is re-read,
not re-queued.

**Why.** Same retirement (PR #10020).

#### Failed checkpoint statuses now all answer `nextAction: 'none'`

**What it was.** `RepositoryCheckpointStatus` carried `nextAction: 'retry'` for
`deadline_exceeded` and `attempts_exhausted`, and `nextAction: 'generate'` for
`invalid_source`. Each named a procedure a reader could call.

**What it is now.** Those three failure codes join `repository_deleted` in a
single variant with `nextAction: 'none'`. The `'retry'` and `'generate'`
members are gone from the union, so a `switch` over `nextAction` that had cases
for them will no longer typecheck against them.

**Migration.**

Before:

```ts
if (status.state === 'failed') {
  switch (status.nextAction) {
    case 'retry':
      await client.repo.checkpoint.retry('acme', 'catalog', status.checkpointId)
      break
    case 'generate':
      await client.repo.checkpoint.generate('acme', 'catalog')
      break
    case 'contact_support':
      report(status.checkpointId, status.failureCode)
      break
  }
}
```

After:

```ts
if (status.state === 'failed') {
  if (status.nextAction === 'contact_support') {
    report(status.checkpointId, status.failureCode)
  } else {
    // Terminal. Take an export instead of trying to revive the checkpoint.
    for await (const row of client.repo.export('acme', 'catalog')) {
      // ...
    }
  }
}
```

**Why.** Each retired value pointed at a route the server no longer serves;
leaving them in the vocabulary would send readers to a 404 (PR #10020).

### Added

- **`client.repo.export(orgName, repoName, options?)`** — an
  `AsyncGenerator<RepositoryExportRow>` over a verified export stream. Options:
  `mode` (`'heads'`, the default, or `'ops'`), `sinceRepoSeq` (delta base;
  `0` means a full export), `atRepoSeq` (pin the fence), `prefer`
  (`'sync'` | `'async'`), `token`, `session`, `afterDurableId`,
  `pollIntervalMs`, and `signal`.

- **`client.repo.exportPrepare(orgName, repoName, options?)`** — returns
  `{ exportToken, atRepoSeq }` without waiting for the fold or reading the
  body. Takes `mode`, `sinceRepoSeq`, `atRepoSeq`, and `signal`.

- **`RepositoryExportSession` / `createRepositoryExportSession()`** — the
  rolling verification state of one logical export: the opening `header`, the
  resume cursor `lastDurableId`, `rowCount`, `complete`, and — once the stream
  is finalized — `contentSha256`. Pass the same session back into `export` to
  resume a stream that broke:

  ```ts
  import {
    createRepositoryExportSession,
    RepositoryExportError,
  } from '@warmhub/sdk-ts'

  const session = createRepositoryExportSession()
  const rows: unknown[] = []
  for (let attempt = 0; attempt < 3 && !session.complete; attempt += 1) {
    try {
      // The session's own cursor and fence pin the resumed request; do not
      // recompute them.
      for await (const row of client.repo.export('acme', 'catalog', {
        session,
      })) {
        rows.push(row)
      }
    } catch (error) {
      if (
        !(error instanceof RepositoryExportError) ||
        error.reason !== 'truncated'
      ) {
        throw error
      }
    }
  }
  console.log(session.rowCount, session.contentSha256)
  ```

- **`readRepositoryExportStream(source, session, expected, options?)`** — read
  a response body you fetched with your own transport, verified against a
  session as it goes. `client.repo.export` is the usual entry point.

- **`restoreRepositoryExportSession(source, options?)`** — the offline twin:
  replay a saved export's bytes back through the same header, canonical-row,
  ordering and trailer checks, and get the session back rather than the rows.
  Pass `{ partial: true }` for a download that was interrupted, then resume
  from the session it returns.

  ```ts
  import { createReadStream } from 'node:fs'
  import { restoreRepositoryExportSession } from '@warmhub/sdk-ts'

  const session = await restoreRepositoryExportSession(
    createReadStream('catalog.ndjson'),
    { partial: true },
  )
  for await (const row of client.repo.export('acme', 'catalog', { session })) {
    // continues from session.lastDurableId
  }
  ```

- **`applyRepositoryExportDelta(base, delta)`** — fold a delta export onto a
  base by `durableId`: active rows upsert, tombstones remove. Pure; neither
  argument is mutated. Both arguments accept either an iterable of rows or a
  `Map` returned by a previous fold, so folds chain.

  ```ts
  import { applyRepositoryExportDelta } from '@warmhub/sdk-ts'

  const session = createRepositoryExportSession()
  const base = []
  for await (const row of client.repo.export('acme', 'catalog', { session })) {
    base.push(row)
  }
  const fence = session.header?.atRepoSeq ?? 0

  // Later: only what changed since that fence.
  const delta = []
  for await (const row of client.repo.export('acme', 'catalog', {
    sinceRepoSeq: fence,
  })) {
    delta.push(row)
  }

  const current = applyRepositoryExportDelta(base, delta)
  ```

  `wref` is an opaque rendering and is never keyed on, so the fold survives a
  rename.

- **`RepositoryExportError`** with a typed `reason`:
  `'count_mismatch'`, `'digest_mismatch'`, `'fence_mismatch'`,
  `'header_invalid'`, `'row_invalid'`, `'row_out_of_order'`,
  `'since_below_epoch_floor'`, `'trailer_invalid'`, `'truncated'`. Every reason
  except `'since_below_epoch_floor'` is a local verification verdict — the
  bytes did not prove what the trailer claimed. `'since_below_epoch_floor'` is
  the server refusing a delta base it no longer retains; recover by re-running
  the export with `sinceRepoSeq: 0`.

- **`RepositoryExportRowMap` / `RepositoryExportRows`** — the collection types
  `applyRepositoryExportDelta` accepts and returns.

### Behavior worth knowing

- **A redeemed token's bytes come from storage, not the API, and the client
  checks what the API said.** A complete redemption answers with a short-lived
  presigned URL rather than the export bytes, and the SDK fetches that URL
  *without* your WarmHub bearer: the signature in the URL is the whole
  capability, and the storage host has no business seeing a credential. The
  record count and content digest the session derives are then checked against
  the ones the API named — a download that does not match raises
  `count_mismatch` or `digest_mismatch` rather than handing you rows nothing
  independent vouched for. A refused or expired URL re-redeems the token, which
  is a deterministic lookup, and retries; a break after rows have already been
  yielded surfaces as an error instead, because a silent restart would hand you
  those rows twice.

- **Ordering is verified, in `heads` mode only.** A heads export is a set,
  emitted in ascending `durableId` by unsigned UTF-8 bytes, and that order is
  part of what the digest proves. A row that does not advance the cursor raises
  `row_out_of_order`. An `ops` export is a log — it repeats identities by
  design — and is not order-checked.

- **Resume trailers are segment-scoped.** A resumed request carries no header,
  and its trailer covers only that segment's rows. The session keeps two
  hashers: a per-segment one the trailer is checked against, and a whole-stream
  one that accumulates across segments. `session.contentSha256` is the
  whole-stream value, and is what you should record as the export's digest.

- **A trailer failure poisons the session.** `truncated` is the resumable
  failure. `count_mismatch`, `digest_mismatch`, `fence_mismatch` and
  `trailer_invalid` are not: the whole-stream digest has already absorbed that
  segment's rows, so the session refuses to resume and you must start a new
  one.

- **`afterDurableId` requires a session with a header.** A resumed request gets
  no header back, so with nothing to check the repository and fence against the
  call is refused before it is sent. Reuse the session the broken stream wrote,
  or rebuild one with `restoreRepositoryExportSession`.

- **The async redemption poll has a floor of 50 ms**, and defaults to 1000 ms.
  Each poll re-runs the full authorization gate, so `pollIntervalMs: 0` — or a
  `NaN` from an unvalidated config value — is clamped rather than honored.

- **Flat server error bodies keep their message.** The export route answers
  with a flat `{ code, message }` body rather than the client's usual nested
  `{ error: { ... } }` envelope. Those responses are re-wrapped before the
  standard mapping runs, so classification stays standard and the server's
  message is not discarded.

### Still supported

The checkpoint **read** plane is untouched: `client.repo.checkpoint.status`,
`.latest`, `.getAccess`, and `verifyRepositoryCheckpointArchive` from
`@warmhub/sdk-ts/checkpoint` all continue to work against archives already in
object storage. Nothing mints new ones.

**Deprecation horizon:** those read surfaces are supported until the announced
cleanup, 30 days after GA. Their removal is a separately-filed post-GA change.
Move download-and-verify workflows to `client.repo.export` before then.
