# 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.TestResult

*class* · *dataclass*

```python
class TestResult
```

Re-exported from: `ocx_sdk._results`

`ocx package test --script` — the stable v1 envelope.

**Only the `--script` form produces this.** The trailing `-- CMD` form
prints the child's raw stdout verbatim, even under `--format json`, so
parsing that output here would either fail loudly or — worse — succeed on
a child that happened to print JSON. The client layer never routes `-- CMD`
output into this parser.

`status` decides pass or fail; `assertion.kind` says why a failure failed.

**Attributes**

- `status` (`str`) — `"passed"` or the failure ocx named.
- `run` (`TestRun | None`) — What the tested command did, or `None` when nothing ran. Always-present-nullable (D7): `script_run.rs:74` carries no `skip_serializing_if`, so a `null` here is ocx saying the script reached no terminal `ocx.run` — not a run whose fields defaulted.
- `assertion` (`Assertion | None`) — The assertion that fired, or `None` when it passed. Always-present-nullable for the same reason (`script_run.rs:73`).

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

### ocx_sdk.TestResult.assertion

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

```python
assertion: Assertion | None = None
```

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

### ocx_sdk.TestResult.run

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

```python
run: TestRun | None = None
```

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

### ocx_sdk.TestResult.status

*attribute* · *instance attribute*

```python
status: str
```

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

### ocx_sdk.TestResult.passed

*property*

```python
passed: bool
```

Whether the test passed — `status` decides, never the exit code.

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

### ocx_sdk.TestResult.from_json

*method* · *classmethod*

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

Parse `ocx --format json package test --script ...` output.

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