Skip to content

Size ​

Type, in @jr2/orchestrator/src/size.ts. It is an export of @jr2/orchestrator, on the Authoring surface page, in Composition.

ts
type Size = {
  limits: {
    memory?: Quantity;
    cpu?: Quantity;
  };
};

The Size of a Workspace: the most memory and cpu that its whole Sandbox can use. jr2 reserves all of it on the node. Thus a Sandbox never gets less than its Size and never uses more.

Write it as { limits: { memory, cpu } }. You can write it in three places: the resources option of workspace(), customize(machine, { resources }), and sandbox.resources in jr2.config.ts. The Size is a fact of the Machine. The Instance's sandbox.resources applies only to a Workspace that states no Size. A field that neither states comes from the kit default: memory 2Gi, cpu 1.

The same shape is the User Container's part of the Size, in user: { image, resources }. There, a field you leave out gives the User Container no limit of its own: it shares the pod's budget.

It refuses any key but limits.memory and limits.cpu, where you write it. The message names the field: <where> is where you wrote the Size, for example workspace(): resources.

  • <where>.requests is not accepted — jr2 reserves the whole Size, so every request equals its limit — a Size is { limits: { memory?, cpu? } } and nothing else — Agent Substrate's template size (ADR-0060)
  • <where>.<key> is not accepted — a Size is { limits: { memory?, cpu? } } and nothing else — Agent Substrate's template size (ADR-0060)
  • <where>.limits.<key> is not accepted — a Size is { limits: { memory?, cpu? } } and nothing else — Agent Substrate's template size (ADR-0060)
  • <where>.limits.memory: <value> is not a positive quantity (e.g. "2Gi", "512Mi"), and for cpu, <where>.limits.cpu: <value> is not a positive quantity (e.g. "2", "1500m")

jr2 up also refuses a Size that leaves the Harness container less than its floor. The message starts with the Size leaves the Harness container <memory> memory, below its 256Mi floor: or with the Size leaves the Harness container no cpu:. The text that follows names each number and where it came from.

Fields

  • limits: object

    The two limits. Write limits: {} to state no field: each field then comes from the next source.

    • memory (optional): Quantity

      The memory limit, as a Kubernetes quantity: "4Gi", "512Mi", or a number of bytes. It must be more than zero. When you leave it out, it comes from the next source, as above.

    • cpu (optional): Quantity

      The cpu limit, as a Kubernetes quantity: "2", "1500m", or a number of cpus. It must be more than zero. jr2 enforces it. When you leave it out, it comes from the next source, as above.

Example

ts
import { customize, type Size } from "@jr2/orchestrator";
import { task } from "@jr2/machines";

const size: Size = { limits: { memory: "4Gi", cpu: "2" } };

export const machine = customize(task, {
  repos: { app: { url: "https://github.com/you/app.git" } },
  agents: { coder: { model: "anthropic/claude-haiku-5-5" } },
  resources: size,
});

See also

The docs of Kit version 0.5.1. Each page is also at its .md URL.