Skip to content

Reusable capability blocks

A reusable capability block is the unit of authored code in Xratu. You write ordinary Python, declare what it needs, and the toolchain turns it into a sealed artifact that workflows call by name and version.

One source module is one block. Each public callable in that module becomes an export of it.

# billing.py
from sdk import xratu
from sdk.auth_declarations import xratu_auth


@xratu(["stripe>=8.0"])
@xratu_auth(requires=["api_key"])
class Billing:
    def charge(self, customer_id: str, amount: int, api_key: str) -> dict:
        ...

    def refund(self, charge_id: str, api_key: str) -> dict:
        ...

Identity

The identity is derived once, from the module and the callables discovered in it.

Identity Derived from This example
reusable_capability_block_id The module name billing
interface_id <module>.<class> when every discovered callable belongs to one class, <module>.<module> otherwise billing.Billing
Export symbol The callable, qualified by its owner when one exists Billing.charge
Export ordinal Assigned by the compiled interface 0, 1

A block with free functions, or with callables spread across several classes, takes the module as its interface name.

Routing addresses the block and the export ordinal. A callable holds no identity of its own outside the interface that carries it.

The lifecycle

flowchart TB
  S["Your source module<br/>plus declarations"]
  S -->|"xratu capability generate"| G["Interface seed, manifest,<br/>adapter manifest, env intent"]
  G -->|"xratu bake"| B["Package artifact<br/>with the block's capsule"]
  B -->|"xratu publish"| P["Release in the catalog"]
  P -->|"imported by version"| W["Workflows and agents"]
Stage What it produces
Generation Discovery documents: identity, exports, declared auth keys, dependency intent
Bake The sealed capsule and its digest
Publish A release record in the catalog, attested and signed
Reuse Any workflow in the organization imports it at a pinned version

Each stage is judged against the one before it. Generation reads source and records what it found; bake seals; publish attests. See Generation boundaries.

What you declare on the source

A block declares two things on its class: @xratu(...) states its Python requirements, system packages and non-secret environment values, and @xratu_auth(requires=[...]) states the secret binding keys it receives.

Declarations are metadata. They install nothing and route nothing at runtime. See Dependency and environment declaration and Secret binding declaration.

Properties

A block is sealed at publish. The bytes that ran are the bytes that were reviewed, and a change is a new version. See Immutability and version pinning.

A block carries its own dependency closure. Requirements are declared per block and resolved into that block's closure, so two blocks in one workflow may use incompatible library versions. See Per-block dependency intent.

A block is reusable across the organization. Publication puts it in a catalog that resolves from every workspace in the organization. See Organizations.