# EXECUTION-PATH INVENTORY & ENFORCEMENT COVERAGE MATRIX
## Project Sovereign — CAIN-42 × TALOS × IHVRK
### Evolution 6: Operation Absolute Sovereign

**Version:** 6.0.0  
**Scope:** Complete inventory of tool, command, and script execution paths in CAIN-42.

---

### Core Enforcement Contract
```
AGENT PROPOSES ──► CAIN-42 JIT EVALUATES ──► TALOS INDEPENDENTLY VERIFIES ──► CONFINED WORKER EXECUTES ──► EVIDENCE RECORDS
                                                     ▲
                                                     │ (Independent Cryptographic & Policy Check)
                                           NO VALID AUTHORIZATION ──► FAIL-CLOSED HALT (Exit 126 / REFUSED)
```

---

### Execution Path Inventory

| Path ID | Entry Point / Invoker | Action Category | Target Resource | Authorization Gate | Enforcement Boundary | OS Confinement Primitives | Residual Risk / Limitation | Status |
|---|---|---|---|---|---|---|---|---|
| `EXEC-SH-01` | `talos-coder` / `executor.py` | `tool.run_command` | `system.shell` | `CainTalosEnvelope` (Ed25519) | `TalosGovernedCommandRunner` | Landlock ABI 8, `PR_SET_NO_NEW_PRIVS`, `RLIMIT_AS`, `RLIMIT_CPU` | Disposable child process; requires valid envelope. Commands without envelope fail closed (exit 126). | **IMPLEMENTED AND TESTED** |
| `EXEC-SH-02` | `OpenShellGateway` (`/fabric/openshell/execute-sandboxed`) | `openshell.exec` | `system.command` | Capability Token / OPA | `OpenShellGateway` subprocess | `PR_SET_NO_NEW_PRIVS`, `RLIMIT_AS`, `RLIMIT_CPU`, sanitised env | In-process gateway dispatches to spawned child; uses prctl + rlimit. Landlock staged. | **IMPLEMENTED AND TESTED** |
| `EXEC-PY-01` | Python Tool Runner | `tool.run_python` | `python.worker` | `CainTalosEnvelope` (Ed25519) | `TalosGovernedPythonRunner` / `TalosWorkerBoundary` | Landlock ABI 8, `PR_SET_NO_NEW_PRIVS`, `RLIMIT_AS`, TCP blocking, sterile env | Dispatched to disposable worker process; gateway process memory completely isolated. | **IMPLEMENTED AND TESTED** |
| `EXEC-FS-01` | Filesystem Read | `fs.read` | Absolute file path | `CainTalosEnvelope` (Ed25519) | `TalosGovernedFilesystem.read_file` | Scope path confinement + Landlock ABI 8 | Paths outside `allowed_read_paths` fail closed with `PermissionError`. | **IMPLEMENTED AND TESTED** |
| `EXEC-FS-02` | Filesystem Write | `fs.write` | Absolute file path | `CainTalosEnvelope` (Ed25519) | `TalosGovernedFilesystem.write_file` | Scope path confinement + Landlock ABI 8 | Paths outside `allowed_write_paths` fail closed with `PermissionError`. | **IMPLEMENTED AND TESTED** |
| `EXEC-MCP-01` | MCP Proxy (`tools/call`) | MCP tool invocation | Downstream MCP Server | JIT Capability Token / ActionDecision | `cain/mcp_proxy.py` (`MCPTransparentProxy`) | Landlock ABI 8 on downstream server process, stdio/JSON-RPC isolation | Dangerous tool calls blocked before downstream dispatch; replay prevented. | **IMPLEMENTED AND TESTED** |
| `EXEC-NET-01` | Tool Outbound Network | Sockets / HTTP | Remote TCP endpoint | `resource_scope.allow_network` | `LandlockProfile.tcp_connect_ports` | Landlock ABI >= 4 `NET_CONNECT_TCP` | Connect blocked fail-closed when `allow_network=False` (`tcp_connect_ports=()`). | **IMPLEMENTED AND TESTED** |
| `EXEC-EXT-01` | Plugin / Extension Execution | Extension invocation | Plugin sandboxes | Extension manifest verification | `cain_extension_hypervisor.py` | Isolated namespace & memory limits | External plugins cannot self-elevate permissions. | **IMPLEMENTED AND TESTED** |
| `EXEC-GW-01` | Hosted Gateway Internal Routes | FastAPI request handling | Internal gateway methods | Gateway API Key / JWT | In-process Python FastAPI runtime | Python process isolation; runs under gateway daemon user | Gateway itself runs as daemon; tool bodies moved to `EXEC-PY-01` / `EXEC-SH-01`. | **PARTIAL** |

---

### Analysis of the Gateway In-Process Gap Remediation

In Evolution 5, the release blocker `BLOCKER-03` noted that:
> *"Hosted in-process gateway tool bodies remain unconfined by Landlock (disposable child processes are confined)."*

**Evolution 6 Remediation:**
1. Created `TalosWorkerBoundary` in [`cain/talos/talos_worker.py`](file:///root/cain-studio-platform/cain/talos/talos_worker.py).
2. All untrusted Python tool scripts and arbitrary function bodies are executed via `TalosGovernedPythonRunner` in a dedicated, disposable subprocess.
3. The child worker process is placed under:
   - Linux Landlock LSM ABI 8 filesystem rules.
   - Outbound TCP network block (`tcp_connect_ports=()`).
   - `PR_SET_NO_NEW_PRIVS` (preventing SUID binary escalation).
   - `RLIMIT_AS` (virtual memory cap) and `RLIMIT_CPU`.
   - Sterile environment stripping all credentials and tokens.
   - Clean stdin/stdout JSON IPC protocol (`close_fds=True`).
4. **Boundary Verdict:**
   - Untrusted tool code executed through `TalosWorkerBoundary` can no longer inspect gateway memory, touch gateway database files, inherit open sockets, or establish unauthorized network egress.
   - The gateway's own web server routing processes remain unconfined in-process (as required for web serving and SQLite database access), but untrusted tool workloads execute in the confined worker sandbox.
