Dependency declaration¶
A block declares on its class. Every export of the class runs with that one declaration.
from sdk import xratu
@xratu(["httpx>=0.27", "orjson>=3.10"], apt=["ca-certificates"], env={"PAGE_SIZE": "100", "LOG": "info"})
class Gateway:
def list(self) -> list:
...
def export(self) -> bytes:
...
How the example reaches the closure, the cell and the kernel¶
Gateway is one block, and it runs as one capsule, one resolved closure and one
cell. Generation records its declaration once for the block:
{
"dependency_intent": {
"python": {"backend": "uv", "requirements": ["httpx>=0.27", "orjson>=3.10"]},
"apt": ["ca-certificates"],
"image": ""
},
"environment_declaration": {
"LOG": "info",
"PAGE_SIZE": "100"
}
}
- The capsule carries that one dependency intent and one environment declaration for the whole block.
- The resolved closure has one dependency binding per entry:
httpx,orjsonandca-certificates, each withrequirement_scope: reusable_block. - The cell mounts every selected component, and its
module_ownershipmaps bothhttpxandorjson.listandexportrun in that same cell. - The kernel dispatches a call to
listorexportby its export ordinal, inside that one cell. Both exports see the same environment values.
How the declaration shapes the cell¶
Every export of Gateway above inherits the class declaration:
flowchart TB
S["gateway.py<br/>class: httpx, orjson, apt ca-certificates"]
S --> L["list resolves<br/>httpx, orjson, apt ca-certificates"]
S --> E["export resolves<br/>httpx, orjson, apt ca-certificates"]
L --> U["Block set<br/>python: httpx, orjson<br/>apt: ca-certificates"]
E --> U
U --> C["One closure<br/>bindings python:httpx, python:orjson<br/>binding bundle:ca-certificates"]
C --> Cell["One cell<br/>import view: httpx, orjson<br/>loader view: ca-certificates"]
The isolation boundary is the block, and the block is the source module: several classes in one module are still one block. An export that needs a dependency or a version the others must not see goes in its own module, which gives it its own closure and cell. See From code to cells for two blocks side by side, and Version coexistence.
One value per environment key across the block¶
A block is one source module, so several classes in one module form one block, with one capsule and one resolved runtime closure. They agree on the value for any given environment key, and two classes that declare different values for one key are refused at generation:
To vary a value per export, pass it as an argument rather than declaring it.
Backend selection¶
The recorded backend is pip when pip=[...] appears and uv otherwise. The
two are exclusive inside one declaration:
The backend is also one per block. Two classes in one module that declare uv
and pip requirements give the block two backends, and generation refuses it:
Declared auth keys¶
Declared auth keys union across every callable in the block, because the process holding the bindings is the block's cell. See Secret binding declaration.
Related: Dependency and environment declaration covers the surface these rules apply to.