# ocx_sdk

*module*

Python SDK for [OCX](https://github.com/ocx-sh/ocx).

`ocx-sdk` drives the ocx binary rather than reimplementing it: ocx owns
resolution, verification, and the identifier grammar, and this package gives
you typed, CWD-independent handles over the commands it exposes.

```python
from ocx_sdk import Ocx, bootstrap

ocx = Ocx(exe=bootstrap.ensure())
project = ocx.project("/srv/build")
project.pull()
project.exec(["task", "verify"])
```

**This module is the API.** Everything listed in `__all__` is the stable
surface; every other module is underscored and package-private, and the one
public submodule is `ocx_sdk.bootstrap`. Reaching into an underscored path
means the next release may move it without notice — pre-1.0, breaking
changes ship without shims.

Start at `Ocx` for the runtime API and `bootstrap.ensure` for provisioning.

[View source](https://github.com/ocx-sh/ocx-sdk-python/blob/main/src/ocx_sdk/__init__.py#L1-L1)

## ocx_sdk.BuildReceipt

*class* · *dataclass*

```python
class BuildReceipt
```

Re-exported from: `ocx_sdk._results`

The `<bundle-stem>-receipt.json` sidecar `ocx package create` writes.

`ocx package receipt <bundle>` prints what `create` was told — the
platform it resolved against and the identifier the bundle will publish
under — so `push` and `test` need not restate either. Both keys are
absent when the build recorded neither, never `null`, so both are read
with `.get`.

The receipt file itself (`<stem>-receipt.json`, `build_receipt.rs`) is
ocx's; this SDK never reads it directly. Its format version stays behind
the command, which answers exit 65 for a file it cannot read and exit 79
for a bundle with no receipt beside it.

**Attributes**

- `platform` (`str | None`) — The `--platform` recorded, canonical grammar, when given.
- `identifier` (`str | None`) — The `--identifier` recorded, resolved against the default registry, when given.

[View source](https://github.com/ocx-sh/ocx-sdk-python/blob/main/src/ocx_sdk/_results.py#L2834-L2871)

### ocx_sdk.BuildReceipt.identifier

*attribute* · *class attribute* · *instance attribute*

```python
identifier: str | None = None
```

[View source](https://github.com/ocx-sh/ocx-sdk-python/blob/main/src/ocx_sdk/_results.py#L2856-L2856)

### ocx_sdk.BuildReceipt.platform

*attribute* · *class attribute* · *instance attribute*

```python
platform: str | None = None
```

[View source](https://github.com/ocx-sh/ocx-sdk-python/blob/main/src/ocx_sdk/_results.py#L2855-L2855)

### ocx_sdk.BuildReceipt.ref

*property*

```python
ref: PackageRef | None
```

The recorded identifier as a `PackageRef`, or `None` when none was recorded.

[View source](https://github.com/ocx-sh/ocx-sdk-python/blob/main/src/ocx_sdk/_results.py#L2859-L2861)

### ocx_sdk.BuildReceipt.from_dict

*method* · *classmethod*

```python
def from_dict(data: Mapping[str, Any]) -> BuildReceipt
```

Build from the decoded report.

[View source](https://github.com/ocx-sh/ocx-sdk-python/blob/main/src/ocx_sdk/_results.py#L2868-L2871)

### ocx_sdk.BuildReceipt.from_json

*method* · *classmethod*

```python
def from_json(raw: str) -> BuildReceipt
```

Parse `ocx --format json package receipt` output.

[View source](https://github.com/ocx-sh/ocx-sdk-python/blob/main/src/ocx_sdk/_results.py#L2863-L2866)
