Dependency and environment declaration¶
@xratu(...) declares what a reusable capability block's source needs: Python
requirements, system packages, and non-secret environment values. The decorator
is read at generation time and recorded as the block's dependency intent.
from sdk import xratu
@xratu(["requests>=2.31.0", "pydantic>=2.6"])
def fetch(url: str) -> dict:
...
The surface¶
| Parameter | Type | Declares |
|---|---|---|
| positional | list of strings | Python requirements, resolved with uv |
uv |
list of strings | Python requirements, resolved with uv |
pip |
list of strings | Python requirements, resolved with pip |
apt |
list of strings | System packages this block needs |
env |
dict of string to string | Non-secret environment values |
A single string is accepted anywhere a list is and normalised to one item.
Choosing a resolver backend¶
uv is the backend for positional and uv requirements. pip is for a package
that requires it.
The two are exclusive within one declaration:
The recorded backend is pip when pip=[...] is used and uv otherwise.
System packages¶
apt is for a package this block needs. The runtime foundation's declared
system baseline is already visible to every block, and project-wide additions
belong in runtime.xratu under document.dependencies.apt.
Environment values¶
@xratu(env={"XRATU_TRACE": "1", "XRATU_RUNTIME_MODE": "batch"})
def process(batch: list) -> dict:
...
env carries stable, non-secret configuration. Secret binding keys are declared
with @xratu_auth(...), which the control plane authorises and the data plane
binds as provider values. See
Secret binding declaration.
Declaring on the class¶
A block declares on its class, and every export of the class runs with that declaration:
@xratu(["httpx>=0.27", "orjson>=3.10"], env={"PAGE_SIZE": "100"})
class Gateway:
def list(self) -> list:
...
def export(self) -> bytes:
...
One value per environment key across the block. A block produces one capsule and one resolved runtime closure, so its exports share one value for a given key.
What the declaration reaches¶
flowchart TB
D["@xratu on the source"]
D -->|"read at generation"| I["dependency_intent<br/>python, apt, image"]
D -->|"read at generation"| E["environment_declaration"]
I --> B["Bake: closure inputs"]
B --> A["Control-plane admission:<br/>resolved closure authority"]
A --> M["Data plane materialises<br/>the admitted artifact set"]
The decorator records intent. It installs nothing, changes no runtime foundation, and routes no invocation.
Declaring a requirement is also what grants import authority for it. A component already present in the foundation is reusable, and presence alone does not let a block import it. See Presence versus import authority.
Next: Per-block dependency intent covers the document this produces and the values it accepts.