ADR-0015: Execution confinement
Status: Accepted — 2026-09-24. The project owner approved this architectural refinement. No confinement implementation or platform support is established by this record; the checks below remain outstanding.
English | Русский
Context and problem
Section titled “Context and problem”Rukh installs trusted extensions into a branded CLI and can expose selected commands through MCP. Trust in a publisher establishes which code the owner admits. It does not restrict the files, networks or credentials that the code can reach after launch. An agent can also misuse a correctly implemented, trusted command.
ADR-0001 deliberately starts with ordinary supervised processes, not an OS sandbox. Task authority limits core-mediated actions, but cannot constrain an extension’s direct system calls by itself. These two properties must not be advertised as equivalent.
Decision drivers
Section titled “Decision drivers”- Keep a small local CLI useful without containers, remote services or corporate identity.
- State the actual execution boundary before allowing a command or advertising it to an agent.
- Enforce required restrictions before any extension or interpreter startup code runs.
- Keep publisher trust, task authority, execution confinement and runtime preparation separate.
- Preserve foreground ownership, resource references, bounded cleanup and no automatic replay.
Considered options
Section titled “Considered options”| Option | Benefit | Limitation |
|---|---|---|
| Treat verified publisher code as restricted | No additional execution work | Confuses code admission with OS authority; direct access bypasses core checks |
| Require one container or WASM engine for all extensions | One preferred mechanism | Excludes ordinary native/scripted tools and assumes a mechanism provides every required guarantee |
| Explicit execution profiles with verified guarantees | Keeps simple trusted execution and supports stronger boundaries | Each executor/platform mapping must demonstrate exactly what it enforces |
Decision
Section titled “Decision”Keep host-trusted execution as the ordinary baseline. A profile requiring confinement admits a command only when an owner-registered executor establishes all required restrictions before untrusted startup. No profile name, descriptor claim, successful handshake or runtime language is evidence of confinement.
Profiles and authority
Section titled “Profiles and authority”| Profile | Selected meaning |
|---|---|
host-trusted | The owner admits the exact extension release to run with the OS authority of the configured process identity. Core dispatch, operations, credentials and task checks still apply at their own boundaries; direct OS access is not claimed to be constrained |
confined | The selected executor enforces the exact filesystem, network, descendant, credential and resource restrictions required by owner policy and the particular invocation. Missing or unverifiable enforcement rejects this invocation |
These are execution profiles, not alternative permission providers. The same Security Broker and task authority apply to both. A local owner may deliberately permit host-trusted extensions in CLI and MCP profiles; this choice must be inspectable before use. A profile that requires confinement cannot be weakened by an agent, extension declaration, ordinary flag, missing platform feature or provider failure. A command that is unavailable through one profile may remain usable through another independently approved profile; failure never switches profiles automatically.
The local baseline needs no new service. Owners can use only trusted native programs with explicit local rules. A stricter local setup can select a supported restricted-process or other executor when one is implemented and verified. A container, WASM engine or remote worker is an optional mapping, not a requirement or an inherited guarantee. This decision selects no such mapping.
The threat boundary excludes a malicious CLI owner, trusted executor implementation and host administrator who can replace the executable, policy or enforcement mechanism. Their trust belongs to application and host distribution. Ordinary extensions cannot modify that trusted implementation catalog.
Trusted registration and enforcement evidence
Section titled “Trusted registration and enforcement evidence”The owner admits implementations through ADR-0010. A descriptor requests restrictions as required features; it cannot supply privileged enforcement code. A trusted registration exposes the following versioned logical contracts; method names and platform APIs are implementation details.
| Contract part | Required contents |
|---|---|
| Static support | Exact executor implementation/version, supported target and execution mappings, individually supported restrictions and known limitations; inspection executes no extension code |
| Restriction plan | Exact release, executable/runtime/dependency bindings, task/owner context, resource identities, allowed operations, channels, descendant rules, credential delivery and finite resource limits |
| Establishment evidence | Plan identity, actual platform mechanisms and configuration, acquired resource identities, verified inheritance restrictions and launch gate; bound to this execution attempt, not copied from an earlier successful launch |
| Runtime supervision | Observable violations, enforcement failures, termination scope, resource accounting and evidence that admitted descendants stay within the same or narrower restrictions |
| Cleanup evidence | Confirmed end of resource use, remaining references and uncertainty; produced within ADR-0004’s unchanged finalization budget |
Evidence is a trusted executor report verified against core-owned bindings. It is not an extension’s self-attestation, a security certificate for all workloads or a promise that an unknown platform defect is impossible. A declared requirement and an actually established restriction are stored separately in safe diagnostics. The advertisement of a confined capability requires the registered, tested platform mapping; launch still checks its actual availability and selected resources each time.
Restriction domains
Section titled “Restriction domains”| Domain | Required rule when that restriction is selected |
|---|---|
| Filesystem | Exact readable/writable resource scope, explicitly separated code and data, and bounded temporary storage. Path spelling alone is insufficient: resolution and use must remain bound against replacement, links, reparse points and traversal |
| Network | Exact permitted destinations and operations through enforced routing or a trusted mediated operation. Resolve the actual destination and apply policy to redirected requests and subsequent connections; a hostname check followed by unrestricted networking is insufficient |
| Child processes | No unapproved program substitution, process escape or inheritance of broader authority. Descendants inherit the same or narrower boundary and remain within the declared supervision scope |
| Credentials and handles | An allowlist of inherited handles, environment and protected credential references. No ambient cloud credentials, user login store, agent socket or privileged IPC endpoint is exposed merely because it exists on the host |
| Resource use | Explicit finite runtime, process/instance count, memory, storage, output and network limits where required by the profile. Shared task accounting follows ADR-0014; starting another child cannot reset its limits |
| Interaction | Core-owned data/interaction channels only. No terminal attachment in a headless invocation, implicit keyboard source or fallback to raw terminal access |
Filesystem enforcement must retain object binding through the relevant operation, not merely call a path-normalization function before opening it. If the desired semantics require a particular object or revision, the operation also verifies its identity/precondition under ADR-0016. A platform that cannot prevent substitution for the required operation reports an insufficient guarantee.
Network authority includes actual recipients. DNS changes, redirects, alternate addresses, proxy behavior and connection reuse cannot broaden the admitted destination. A new destination requires a new check before use. Where resource- or method-level control is needed, unrestricted access to the service’s IP address is not equivalent; use a trusted operation that enforces the requirement. Encryption does not make the recipient authorized.
An extension with direct permitted access may still misuse that access. In particular, confinement alone does not establish effect commitment and repeat protection, semantic correctness, resistance to every data leak or absence of covert channels. A profile requiring controlled external effects must route those actions through a contract capable of enforcing them.
Preparation and launch
Section titled “Preparation and launch”Static support and mandatory access checks precede environment preparation. Runtime preparation retains ADR-0008: a trusted provider performs its separately authorized exact plan, with its own bounded preparation context. The future extension boundary does not silently protect the preparer or authorize downloads, lifecycle hooks, global installations or wider credentials.
The executor checks prepared runtime, executable and dependency identities against the restriction plan. Borrowed or externally mutable runtimes are supported only when the required identity and restrictions can be retained through startup and use. Rechecking a path once does not prevent replacement. A stricter mapping may use a verified immutable snapshot or other proven binding; it may not silently copy unverified bytes or modify a shared runtime to obtain one.
The launch gate includes interpreter startup, imported dependencies and native entry-point initialization. A managed IPC handshake happens later and cannot establish restrictions retroactively. Ordinary process-only commands are subject to the same gate even though they have no handshake. A failed static requirement yields rejected; establishment/startup failure after preparation follows execution_failed, unless the existing cancellation rules govern. No new final outcome is introduced.
Owner policy can require a narrower child boundary or forbid children. Descendants are admitted only within the selected contract. A declared descendant request does not authorize another runtime or arbitrary executable lookup. An enforcement loss stops further core-operation admission, requests termination and reports failure or the already accepted cancellation; previously performed effects remain recorded. It cannot turn the invocation into host-trusted execution.
Lifetime and cleanup
Section titled “Lifetime and cleanup”The common foreground lifecycle remains unchanged. A long-lived MCP host can own several bounded invocation scopes; this does not make extension processes background workers. Closing an owning scope stops admission and initiates the existing bounded finalization. A raw transport disconnect is handled by the selected host contract, not interpreted by an extension as permission to detach.
Termination evidence covers the whole admitted execution scope, including descendants and engine instances. An escaped or unconfirmed descendant prevents a clean success and retains protective release/environment references. Exhausting the fixed cleanup deadline reports uncertainty; it never claims that resources are gone or starts an unlimited cleanup loop. Later authorized reconciliation can release a reference after proving that use ended, without restarting work. Revocation prevents new protected actions but cannot undo completed effects.
Bounds and compatibility
Section titled “Bounds and compatibility”Use the selected invocation, output, concurrency and finalization limits from ADR-0002–0004/0010 and task ceilings from ADR-0014; the smallest applicable limit wins. Each additional restriction domain has a finite owner-selected bound validated against the registered executor’s supported range before launch. An omitted bound cannot satisfy a profile that requires that restriction. No universally safe memory, network or process-count limit is inferred from the old startup benchmark.
Restriction plans fit ADR-0006’s prepared-invocation budget; evidence and diagnostics obey ADR-0003’s selected message limits when sent over that binding. A trusted in-process mapping must impose equivalent finite limits rather than relying on an IPC frame limit it does not have. Unsupported limits fail explicitly. Existing host-trusted declarations remain usable under an explicitly compatible owner profile; adding a confinement requirement is a compatibility change requiring a supported mapping.
Consequences
Section titled “Consequences”- Small teams retain ordinary trusted extensions and local policy. They can adopt verified restrictions without operating a new service.
- Agents and operators can distinguish accepted code from constrained code. Permission checks cannot accidentally advertise OS isolation.
- Executor/platform implementations carry additional enforcement and conformance work; this record makes no claim of completed Windows, Unix or WASM support.
- Restriction enforcement and effect control remain complementary. Neither replaces publisher verification, authorization or command correctness.
Confirmation
Section titled “Confirmation”The architecture is accepted; the following implementation checks have not been run:
- Each admitted platform mapping establishes restrictions before native, interpreter and dependency startup. Unsupported/failed restrictions never launch through a weaker mapping.
- Path replacement, links/reparse points, runtime replacement, DNS changes, redirects, proxies and inherited handles cannot escape the required resource binding; unsupported cases reject explicitly.
- Direct files/network access, child programs, terminal devices and ambient credentials match the advertised profile. Ordinary host-trusted execution is never described as confined.
- Preparation uses its own exact authorized scope. Concurrent waiters, cancellation and borrowed environments do not broaden the command’s authority or corrupt a shared environment.
- Descendants, enforcement loss, host exit and cleanup timeout preserve one outcome and protective references. Task resource ceilings include admitted descendants; a new process cannot reset them.
The earlier process/IPC experiments do not validate these properties. Before advertising a concrete confined mapping, retain its exact platform/configuration support matrix and these conformance results.