Skip to content

feat(client): a call limit takes a cost for each call (CLI-122) - #496

Merged
mark1russell7 merged 7 commits into
mainfrom
feat/cli-122-call-cost
Nov 15, 2026
Merged

mark1russell7 merged 7 commits into
mainfrom
feat/cli-122-call-cost

Conversation

@mark1russell7

Copy link
Copy Markdown
Owner

What

A call limit takes a cost for each call (roadmap CLI-122). With merged pushes, one batch of 100 items cost one unit, the same as one call. CallLimit gets the field cost: a whole number of 1 or more, or a function of the call. The default is 1.

  • The server takes cost units in one atomic step with take(key, units) of @mark1russell7/service 0.7.0.
  • A cost over the burst or the limit of the policy gets a capacity refusal. Its code is PAYLOAD_TOO_LARGE, not retryable. The metadata has reason: "capacity", units and capacity.
  • The HTTP face answers 413 with units and capacity in the body and no Retry-After. The HTTP client, the batch, the WebSocket and the MCP faces carry both numbers.
  • The transport contract has a case for the capacity refusal, and each face examines it.
  • Each package uses @mark1russell7/service ^0.7.0, so the lockfile holds one version of it.

Version

MINOR of the client group (D13, a break before 1.0). In service 0.7.0, Refused is a union, and only a wait refusal has retryAfter. limiters() gives the keyed limiters of the service, so code that reads retryAfter of their decisions does not compile. The changeset gives the migration steps.

Merge order

This break merges alone, after the release of #489 (0.53.0). It stays a draft until then.

🤖 Generated with Claude Code

mark1russell7 and others added 7 commits November 8, 2026 00:44
… refusal is a 413 (CLI-122)

WIP: this code is written against @mark1russell7/service 0.7.0
(systems#408: take(key, units), the union Refused). The dependency
stays ^0.6.0 until 0.7.0 is on npm, thus this commit does not compile
yet. The next commit raises it to ^0.7.0.

- CallLimit.cost: a whole number of 1 or more, or a function of the
  call (default 1). admit() takes that many units of each limit.
- A capacity refusal is PAYLOAD_TOO_LARGE, not retryable, with the
  metadata reason "capacity", units and capacity. HTTP answers 413
  with both numbers in the body and no Retry-After. The HTTP client,
  the HTTP batch and the MCP face carry both numbers. WebSocket
  carries the metadata as it is.
- ContractSpec.limits: the transport contract checks the capacity
  refusal on each server face.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…al only (service 0.7.0)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…to the policy (CLI-122)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	packages/client-mongo/package.json
#	packages/client/package.json
#	pnpm-lock.yaml
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mark1russell7
mark1russell7 marked this pull request as ready for review November 15, 2026 16:42
@mark1russell7
mark1russell7 merged commit 11f5035 into main Nov 15, 2026
29 checks passed
@mark1russell7
mark1russell7 deleted the feat/cli-122-call-cost branch November 15, 2026 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant