> ## Documentation Index
> Fetch the complete documentation index at: https://ibm-llm-runtime-aaf3a78b.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# mellea.stdlib.tools.execution_policy

> Capability policy, artifact model, and compatibility matrix for code execution environments.

export const SidebarFix = () => <script dangerouslySetInnerHTML={{
  __html: `
        (function () {
          const INTERVAL_MS = 500;

          const upgradeSidebar = () => {
            const links = document.querySelectorAll('a[href^="#"]');

            links.forEach((link) => {
              if (link.dataset.badged === "true") return;

              const rawText = (link.textContent || "").trim();

              // ========== FUNC ==========
              if (rawText.startsWith("FUNC ")) {
                const label = rawText.replace(/^FUNC\\s+/, "").trim();

                while (link.firstChild) link.removeChild(link.firstChild);

                // 👉 Make the whole link a single flex row & prevent wrapping
                link.style.display = "flex";
                link.style.alignItems = "center";
                link.style.whiteSpace = "nowrap";
                link.style.columnGap = "0.5rem";

                const badge = document.createElement("span");
                badge.style.marginRight = "0.5rem";
                badge.style.display = "inline-flex";
                badge.style.alignItems = "center";
                badge.style.borderRadius = "9999px";
                badge.style.padding = "0rem 0.6rem";
                badge.style.fontSize = "0.5rem";
                badge.style.fontWeight = "700";
                badge.style.letterSpacing = "0.05em";
                badge.style.backgroundColor = "rgba(48, 100, 227, 0.20)";
                badge.style.color = "#1D4ED8";

                badge.textContent = "FUNC";

                link.appendChild(badge);
                link.appendChild(document.createTextNode(label));
                link.dataset.badged = "true";
                return;
              }

              // ========== CLASS ==========
              if (rawText.startsWith("CLASS ")) {
                const label = rawText.replace(/^CLASS\\s+/, "").trim();

                while (link.firstChild) link.removeChild(link.firstChild);

                // 👉 Same flex / nowrap treatment for class links
                link.style.display = "flex";
                link.style.alignItems = "center";
                link.style.whiteSpace = "nowrap";
                link.style.columnGap = "0.5rem";

                const badge = document.createElement("span");
                badge.style.marginRight = "0.5rem";
                badge.style.display = "inline-flex";
                badge.style.alignItems = "center";
                badge.style.borderRadius = "9999px";
                badge.style.padding = "0rem 0.6rem";
                badge.style.fontSize = "0.5rem";
                badge.style.fontWeight = "700";
                badge.style.letterSpacing = "0.05em";
                badge.style.backgroundColor = "rgba(74, 222, 128, 0.20)";
                badge.style.color = "#15803D";

                badge.textContent = "CLASS";

                link.appendChild(badge);
                link.appendChild(document.createTextNode(label));
                link.dataset.badged = "true";
                return;
              }
            });
          };

          upgradeSidebar();
          setInterval(upgradeSidebar, INTERVAL_MS);
        })();
      `
}} />;

<SidebarFix />

Capability policy, artifact model, and compatibility matrix for code execution environments.

Four execution tiers are available, selectable by intent rather than by class name:

* `"local_unsafe"`  — subprocess in the current Python env, no policy applied.
* `"local"`         — subprocess in the current Python env, policy declared and partially enforced.
* `"docker_unsafe"` — Docker-isolated execution via llm-sandbox, no policy applied.
* `"docker"`        — Docker-isolated execution via llm-sandbox, policy declared and partially enforced.

`CapabilityPolicy` declares what a code execution environment is *allowed* to do.
Enforcement is honest: each capability has a companion `ENFORCED_*` class attribute
indicating whether the declared value is actively enforced at runtime or is informational
only.

`Artifact` represents a file produced by execution and exported from the environment.

`COMPATIBILITY_MATRIX` records which capabilities each tier supports.

## Classes

<div className="w-full h-px bg-gray-200 dark:bg-gray-700 my-4" />

### <span className="ml-2 inline-flex items-center rounded-full px-2 py-1 text-[0.7rem] font-bold tracking-wide bg-[#4ADE8033]/20 text-[#15803D]">CLASS</span> `Artifact` <sup><a href="https://github.com/generative-computing/mellea/blob/v0.7.0.dev0/mellea/stdlib/tools/execution_policy.py#L28" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

A file produced by code execution and exported from the execution environment.

**Args:**

* `path`: Absolute path on the host where the artifact was written.
* `size_bytes`: File size in bytes, or `None` if unknown.
* `content_type`: MIME type or informal label (e.g. `"text/csv"`,
  `"image/png"`), or `None` if undetermined.

<div className="w-full h-px bg-gray-200 dark:bg-gray-700 my-4" />

### <span className="ml-2 inline-flex items-center rounded-full px-2 py-1 text-[0.7rem] font-bold tracking-wide bg-[#4ADE8033]/20 text-[#15803D]">CLASS</span> `CapabilityPolicy` <sup><a href="https://github.com/generative-computing/mellea/blob/v0.7.0.dev0/mellea/stdlib/tools/execution_policy.py#L44" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

Declared capabilities and resource limits for a code execution environment.

The enforcement gap — the difference between what is *declared* and what is
*actively enforced at runtime* — is made explicit through per-field
`ENFORCED_*` class attributes.  Callers and UX layers can read these to
decide whether to prompt the user ("allow once / allow always") or display
a warning.

**Args:**

* `filesystem_read_roots`: Host paths the environment may
  read.  `None` means unrestricted.  Declared only — not enforced.
* `filesystem_write_roots`: Host paths the environment may
  write.  `None` means unrestricted.  Declared only — not enforced.
* `network_access`: Whether outbound network connections are allowed.
  Defaults to `False`.  Declared only — not enforced.
* `package_installation`: Whether the environment may install packages.
  Declared only — not enforced.
* `subprocess_execution`: Whether spawning child processes is allowed.
  Declared only — not enforced.
* `env_var_access`: Whether environment variables are readable.
  Declared only — not enforced.
* `timeout`: Wall-clock seconds before execution is killed.  Enforced.
* `stdout_max_bytes`: Truncate stdout to this byte count; `None`
  disables truncation.  Enforced.
* `stderr_max_bytes`: Truncate stderr to this byte count; `None`
  disables truncation.  Enforced.
* `artifact_export_paths`: Paths inside the container/environment
  to copy out after execution as `Artifact` objects.  Enforced.
* `packages`: Python packages to install (via `pip install`) before
  execution.  Enforced — the runtime installs packages prior to executing
  user code and aborts with a skipped `ExecutionResult` if installation
  fails.  Failed packages are not retried on subsequent calls (clear
  `_failed_packages` on the environment to force a retry).  Local tiers
  use `uv pip install` / `python -m pip`; Docker tiers run
  `pip install` inside the container.  Defaults to `[]`.

<div className="h-8" />

**Methods:**

<div className="w-full h-px bg-gray-200 dark:bg-gray-700 my-4" />

#### <span className="ml-2 inline-flex items-center rounded-full px-2 py-1 text-[0.7rem] font-bold tracking-wide bg-[#3064E3]/20 text-[#1D4ED8]">FUNC</span> `unenforced_capabilities` <sup><a href="https://github.com/generative-computing/mellea/blob/v0.7.0.dev0/mellea/stdlib/tools/execution_policy.py#L108" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python theme={null}
unenforced_capabilities(self) -> list[str]
```

Return capability names that are declared but not enforced at runtime.

**Returns:**

* list\[str]: Field names whose declared values are informational only.

<div className="w-full h-px bg-gray-200 dark:bg-gray-700 my-4" />

#### <span className="ml-2 inline-flex items-center rounded-full px-2 py-1 text-[0.7rem] font-bold tracking-wide bg-[#3064E3]/20 text-[#1D4ED8]">FUNC</span> `enforced_capabilities` <sup><a href="https://github.com/generative-computing/mellea/blob/v0.7.0.dev0/mellea/stdlib/tools/execution_policy.py#L120" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python theme={null}
enforced_capabilities(self) -> list[str]
```

Return capability names that are actively enforced at runtime.

**Returns:**

* list\[str]: Field names whose declared values are honoured by the runtime.

<div className="w-full h-px bg-gray-200 dark:bg-gray-700 my-4" />
