# Runtime

> Run commands and prepared processes under compiled sandbox authority with explicit lifecycle and error contracts.

- Path: `Guides > Sandboxing > Runtime > Runtime`
- Human: https://looprig.com/docs/guides/sandboxing/runtime
- Machine index: https://looprig.com/llms.txt

The runtime subtree is where an owned `Executor` turns compiled policy into work. Synchronous calls collect bounded or unbounded output. Prepared processes reserve authority before spawning and then expose live pipes, signal, wait, and lifetime-containment behavior.

## How it works

An `ExecutorSet` owns the shared lifecycle. `For(key)` returns a memoized executor with an executor-bound grant key and per-key `HOME` and `TMPDIR`. `RunArgv` and `PrepareProcess` check command access before the native spawn path. `Close` cancels outstanding work and releases the set-owned resources.

```go
package example

import (
	"context"

	"github.com/looprig/sandbox"
)

func run(executor *sandbox.Executor, workspace string) error {
	_, _, err := executor.RunArgv(context.Background(), workspace, []string{"true"})
	return err
}
```

## Start here

- [Executors and ExecutorSets](/docs/guides/sandboxing/runtime/executors.md) explains ownership and memoization.
- [RunArgv and confinement](/docs/guides/sandboxing/runtime/argv-and-confinement.md) explains shell and argv choices.
- [Prepared processes and lifetime](/docs/guides/sandboxing/runtime/processes.md) explains streaming and teardown.
- [Typed errors and recovery](/docs/guides/sandboxing/runtime/errors.md) explains fail-closed handling.
- [Harness gates and prepared Tools](/docs/guides/sandboxing/integration/index.md) explains how approved effects reach this runtime.

## Source

- [Executor and process facade](https://github.com/looprig/sandbox/blob/main/sandbox.go)

## Proof

- [Policy and enforcement runtime fixture](https://github.com/looprig/sandbox/blob/main/examples/policy-enforcement/example_test.go)
