---
model: claude-fable-5
service: claude
timestamp: 2026-07-02T15:42:55Z
git_ref: 65bf9df5
diff_cmd: git diff main..wkt/to_actor_subpkg
---

# Raw AI output (diff-ref mode)

All generated code is committed on the
`wkt/to_actor_subpkg` branch; per diff-ref mode each
file's verbatim content is reachable via the pointers
below rather than duplicated here.

## Generated files

> `git diff main..wkt/to_actor_subpkg -- tractor/to_actor/__init__.py`

New subpackage init: module docstring establishing the
`trio.to_thread`/`anyio.to_process` "run it over there"
parlance for actors, plus the single public re-export
`run as run` from `._api`.

> `git diff main..wkt/to_actor_subpkg -- tractor/to_actor/_api.py`

The one-shot invocation impl, composed entirely from the
lower level daemon-spawn + portal primitives as
prescribed by issue #477:

- `_validate_one_shot_fn()`: the `Portal.run()`
  non-streaming-async-fn constraint checked up-front,
  before any subactor is spawned.
- `_invoke_in_subactor()`: `an.start_actor()` ->
  `Portal.run()` -> always-reap via
  `Portal.cancel_actor()` in a `finally` (the cancel
  req's bounded wait is internally shielded so the reap
  also runs under caller-scope cancellation).
- `run()`: the public API. Placement options:
  `portal=` (reuse a running actor, no spawn/reap),
  `an=` (spawn from a caller-managed nursery), or
  neither (private `open_nursery()` scoped to the call,
  implicitly booting the runtime when needed, tunable
  via pass-through `runtime_kwargs`). Spawn opts mirror
  `ActorNursery.start_actor()`; `**fn_kwargs` are
  relayed to the remote task. Errors raise in the
  caller's task as boxed `RemoteActorError`s.
  `runtime_kwargs` alongside any placement opt is a
  hard `ValueError`, never silently ignored.

> `git diff main..wkt/to_actor_subpkg -- tractor/__init__.py`

Top-level `from . import to_actor as to_actor`
re-export.

> `git diff main..wkt/to_actor_subpkg -- tractor/runtime/_supervise.py`

Comment/docstring-only: the `run_in_actor()` deprecation
TODO now points at the implemented `.to_actor.run()`
successor (checkbox ticked) and the method docstring
gains a NOTE steering users to the new API; remaining
TODO items are the `DeprecationWarning` emission +
in-repo usage migration.

> `git diff main..wkt/to_actor_subpkg -- tests/test_to_actor.py`

11-test suite: private-nursery one-shot, implicit
runtime boot via `runtime_kwargs`, remote-error relay to
the caller's task (bare + caller-managed nursery),
caller-nursery spawn, portal reuse w/o implicit reap,
the concurrent worker-pool-ish pattern (local `trio`
nursery x shared `an`), and the four validation
rejections (sync fn, async-gen fn, `portal`+`an`
combo, `runtime_kwargs`+placement combo).

> `git diff main..wkt/to_actor_subpkg -- examples/parallelism/to_actor_one_shots.py`

Runnable example (auto-collected by
`test_docs_examples.py`): the fully-implicit one-shot
plus the concurrent worker-pool-ish prime-check pattern
against a shared caller-managed actor-nursery.

## Test runs (verbatim)

```
tests/test_to_actor.py ..........                [100%]
============= 10 passed in 4.29s =============
```

Regression subset for touched modules
(`test_local.py test_rpc.py test_spawning.py
test_cancellation.py`):

```
38 passed, 1 xfailed, 24 warnings in 80.71s (0:01:20)
```

(warnings are pre-existing stdlib `os.fork()`
DeprecationWarnings from the mp spawn backends, not
introduced by this change)
