|
| 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). |
0 commit comments