Skip to content

Commit c083d1d

Browse files
committed
Add verified offline foundation for Debian agent zones
1 parent cd09084 commit c083d1d

16 files changed

Lines changed: 5788 additions & 1 deletion

‎docs/agent-zones.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Deploy in the following order. A stage passes only when its behavior is demonstr
2525

2626
1. **Build the reproducible guest.** Pin an immutable official [Debian cloud-image build](https://cloud.debian.org/images/cloud/trixie/), its architecture and checksum. Prepare packages and agent tools in a disposable build VM with temporary networking, no production credentials and no host mounts. Record the Debian package snapshot and versions, exact tool commits and artifact hashes. Generate separate operator and per-instance guest SSH identities, bake bounded socket relays and create an immutable base. Remove the build NIC and seed before production. Production first boot must not depend on downloading packages.
2727

28-
2. **Install the protected host foundation.** Create distinct nonadministrator identities for each hypervisor, broker and inference service. Install reviewed code, interpreters, dependencies, service definitions, policy, working directories and search paths under root-controlled ownership. Neither guests nor service accounts may change this execution chain. Keep zone disks, sockets, logs, credentials, indexes and caches separate; cap logs and storage. Verify ownership and reject symlinks and writable ancestors. Build native Metal inference services with separate writable state and prompt caches; read-only weights may share storage. Enforce fixed peers and destinations below broker processes, including attempts through DNS and other host services. This operating-system confinement remains a production gate.
28+
2. **Install the protected host foundation.** Create distinct nonadministrator identities for each hypervisor, broker and scoped integration service. Install reviewed code, interpreters, dependencies, service definitions, policy, working directories and search paths under root-controlled ownership. Neither guests nor service accounts may change this execution chain. Keep zone disks, sockets, credentials, files and client state separate; cap logs and storage. Verify ownership and reject symlinks and writable ancestors. Retain the existing oMLX inference server using native Metal behind the Slopgate model gateway: one 125-billion-parameter model per Mac host, serving mixed concurrent requests from both zones. Both zones trust that shared inference service; separate model processes, duplicate models and model switching are not required. Guests receive only fixed inference routes, without access to model administration or other clients' requests, logs and cache files. Enforce fixed peers and destinations below broker processes, including attempts through DNS and other host services. This operating-system confinement remains a production gate.
2929

3030
3. **Add scoped services.** Model Context Protocol (MCP) integrations, including [Sloptools](https://github.com/sloppy-org/sloptools) and [Helpy](https://github.com/sloppy-org/helpy), need restricted endpoints at their owning services. Do not forward a generic namespace through a filter. Validate complete typed schemas, reject unknown nested fields, and authorize each operation, account and object. Guests cannot select configuration paths, credentials, commands, upstreams or plugins. Internal services hold no confidential credentials. Untrusted documents and previews run without network or secrets. Missing policy and service failures must deny access.
3131

‎sandbox/README.md‎

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# Agent-zone foundation
2+
3+
This library in [the infrastructure repository](https://github.com/itpplasma/code)
4+
provides offline building blocks for the fixed `internal` and `confidential`
5+
Debian virtual machines (VMs). It does not deploy host services or provide a
6+
complete `ai` command. Production use requires the acceptance gates below.
7+
8+
## Available components
9+
10+
| Module | Implemented scope |
11+
|---|---|
12+
| [`policy.py`](ai_zones/policy.py) | Strict, immutable policy schema; explicit protected-path loading; root ownership, modes, symlink and native macOS access-control checks. |
13+
| [`release.py`](ai_zones/release.py) | Offline public-key signature and payload-hash verification; root-only tool installation from retained verified bytes with atomic `current` selection. |
14+
| [`vm.py`](ai_zones/vm.py) | Fixed vfkit and QEMU command builders, resource validation and distinct Secure Shell (SSH) transport helpers; builders never launch a VM. |
15+
| [`guest.py`](ai_zones/guest.py) | Debian 13 raw-image checksum verification, NoCloud seed generation and fixed guest relay source and units. |
16+
| [`confinement.py`](ai_zones/confinement.py) | macOS Seatbelt profile and launch-argument generation with a tested-build gate; an explicitly untested Linux systemd namespace fragment. |
17+
| [`runtime.py`](ai_zones/runtime.py) | Bounded signed Python runtime manifests and verification, plus a root-only installation interface separate from the tool updater. |
18+
19+
[`policy.example.json`](policy.example.json) contains synthetic paths and model
20+
settings. Schema validation alone grants no authority. Protected loading requires
21+
an explicit normalized absolute path whose complete ancestry passes protection
22+
checks; environment variables and the current directory do not select policy.
23+
Confidential model origins must use literal loopback addresses, without name
24+
resolution.
25+
26+
## Release and runtime trust
27+
28+
Tool bundles contain `manifest.json`, `manifest.sig` and `payload/`. Verification
29+
uses the supplied RSA public key, SHA-256 hashes and local `/usr/bin/openssl`;
30+
it downloads nothing and runs no payload code. Manifests allow bounded Python files and named entry
31+
points, with hashes for every payload file. Verification with a caller-selected
32+
key is a consistency check, not deployment approval.
33+
34+
Production installation requires an independently approved, frozen privileged
35+
core, its Python dependencies, protected public keys and a root-controlled
36+
destination. Ordinary signed tool releases must neither replace that core nor
37+
be imported by its privileged installer. Keep signing keys outside agent and
38+
service-account access. Policy, credentials and revocations remain outside tool
39+
releases; selecting older code must not restore older authority.
40+
41+
The Python runtime has its own signed complete-tree manifest and trust key.
42+
Its current schema supports pinned macOS 64-bit Arm Python bundles; a Linux prefix
43+
in the installer does not establish Linux runtime support. Bundle verification
44+
does not turn mutable source files into a trusted installed interpreter. Runtime
45+
installation and launch-time integrity checks need their own approval and tests;
46+
the runtime command line exposes build and verify operations, not installation.
47+
48+
## Fixed guest channels
49+
50+
macOS uses vfkit with raw SSH over its fixed Unix socket. Linux uses QEMU with
51+
one `vhost-device-vsock` backend per VM and zone-specific identities and groups;
52+
its SSH helper exchanges `CONNECT 2222` / `OK 2222` before SSH bytes. These
53+
transports are distinct and must not share the same connection helper.
54+
55+
Guest relays expose only virtual-socket port 2222 to guest-local SSH port 22,
56+
and guest-local Transmission Control Protocol (TCP) port 5001 to host
57+
virtual-socket port 5001. Command builders
58+
emit no network interface, shared host filesystem or management interface.
59+
Arguments alone do not prove isolation at runtime.
60+
61+
Seed generation writes staging files. Applying that seed later inside a guest
62+
installs and starts its SSH and broker relays. It does not prepare missing
63+
packages or fetch dependencies. No host services are installed or activated by
64+
generating seeds, profiles, unit fragments or VM arguments.
65+
66+
## Verification and deployment gates
67+
68+
From the repository root, run the affected standard-library unittest suite:
69+
70+
```sh
71+
python3 -m unittest discover -s tests -p 'test_agent_zone_*.py' -q
72+
```
73+
74+
Tests use synthetic data, temporary signing/SSH keys and local sockets. They
75+
require `/usr/bin/openssl` and `/usr/bin/ssh-keygen`; the SSH configuration probe
76+
also uses an available SSH server. Live Seatbelt tests require macOS, their
77+
canonical test interpreter and the exact build named in `confinement.py`.
78+
Optional staged-runtime probes use `AI_ZONES_TEST_RUNTIME_ROOT`; shared-policy
79+
integration probes use `AI_ZONES_POLICY_SOURCE`. Inspect skips before claiming
80+
that a platform or interpreter passed.
81+
82+
Before admitting real data, verify the entire protected execution chain and
83+
signed installed runtime, reserve distinct ports for different service roles,
84+
close inherited descriptors, clear the environment and set a fixed working
85+
directory. Retest Seatbelt after a system or runtime change. Its measured
86+
exceptions expose top-level root names and, when enabled, public system and
87+
hostname information.
88+
Linux needs real namespace, isolated-root and Unix model-adapter probes.
89+
90+
Boot both guests and test pinned SSH identities, persistence, resource and log
91+
limits, absent network/shares, arbitrary-port denial and sibling-zone denial.
92+
Approve image provenance separately from checksum matching. Validate scoped
93+
service authorization, updates, rollback and encrypted recovery before cutover.
94+
The full deployment acceptance plan is in [agent-zones.md](../docs/agent-zones.md).

‎sandbox/ai_zones/__init__.py‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""Two-zone AI sandbox: fail-closed policy loading and signed release installs.
2+
3+
Zones are fixed: ``internal`` and ``confidential``. Nothing in this package
4+
searches the environment or the current directory for configuration, executes
5+
payload code, or modifies policy or secrets.
6+
"""
7+
8+
from ai_zones.policy import (
9+
Policy,
10+
PolicyError,
11+
assert_protected,
12+
load_policy,
13+
validate_policy,
14+
)
15+
16+
__all__ = [
17+
"Policy",
18+
"PolicyError",
19+
"assert_protected",
20+
"load_policy",
21+
"validate_policy",
22+
]

0 commit comments

Comments
 (0)