# Class LittleGhost::Sandbox::Scope

Documentation version: Edge

Canonical HTML: https://littleghostai.org/docs/LittleGhost/Sandbox/Scope.html

A non-owning, capability-reduced view of a Sandbox for one agent or Tool set.
Scopes never open or close their parent and cannot widen it. They constrain
only callers that receive and use the Scope; code retaining the parent Sandbox
retains its broader authority.

## Inheritance

`LittleGhost::Sandbox::Scope < Object`

## Attributes

<a id="attribute-i-capabilities"></a>
### `capabilities` (R)

Operations exposed through this scope.

<a id="attribute-i-network"></a>
### `network` (R)

Outbound connectivity available to processes launched through this scope.

<a id="attribute-i-sandbox"></a>
### `sandbox` (R)

Sandbox that enforces process execution.

## Class methods

<a id="method-c-new"></a>
### `.new`

```ruby
.new(sandbox:, files: nil, runtime_paths: nil, capabilities: nil, network: nil, parent_scope: nil)
```

Creates a view of `sandbox`. `mounts` and `capabilities` may only narrow the
parent scope or sandbox.

## Instance methods

<a id="method-i-allows-3F"></a>
### `#allows?`

```ruby
#allows?(operation, path = nil)
```

Indicates whether `operation` is available at optional virtual `path`.

<a id="method-i-close"></a>
### `#close`

```ruby
#close()
```

Scopes own no resources, so closing has no effect.

<a id="method-i-effective_policy"></a>
### `#effective_policy`

```ruby
#effective_policy()
```

Effective policy enforced by the parent sandbox.

<a id="method-i-execute"></a>
### `#execute`

```ruby
#execute(command, **options)
```

Executes a shell command through the parent sandbox and this scope.

<a id="method-i-execute_program"></a>
### `#execute_program`

```ruby
#execute_program(command, **options)
```

Executes an argument vector through the parent sandbox and this scope.

<a id="method-i-list"></a>
### `#list`

```ruby
#list(path = ".", context: nil)
```

Lists one directory through the scoped filesystem.

<a id="method-i-open"></a>
### `#open`

```ruby
#open(run: nil)
```

Scopes own no resources; opening returns the same object.

<a id="method-i-policy"></a>
### `#policy`

```ruby
#policy()
```

Effective policy enforced by the parent sandbox.

<a id="method-i-read"></a>
### `#read`

```ruby
#read(path, context: nil)
```

Reads bounded UTF-8 text through the scoped filesystem.

<a id="method-i-replace"></a>
### `#replace`

```ruby
#replace(path, old_text, new_text, context: nil)
```

Replaces one unique text occurrence through a writable scoped mount.

<a id="method-i-scope"></a>
### `#scope`

```ruby
#scope(**options)
```

Produces another view that can only narrow this scope.

<a id="method-i-supports-3F"></a>
### `#supports?`

```ruby
#supports?(feature, value = nil)
```

Indicates whether this scope exposes `feature`.

<a id="method-i-validate-21"></a>
### `#validate!`

```ruby
#validate!()
```

Fails closed if a selected host mount was replaced after scope creation.

<a id="method-i-workspace"></a>
### `#workspace`

```ruby
#workspace()
```

Workspace owned by the parent sandbox.

<a id="method-i-writable-3F"></a>
### `#writable?`

```ruby
#writable?()
```

Indicates whether any visible mount accepts writes.

<a id="method-i-write"></a>
### `#write`

```ruby
#write(path, content, context: nil)
```

Writes bounded content through a writable scoped mount.
