|
| 1 | +# Agent Mode |
| 2 | + |
| 3 | +Policy-bound local autopilot for SecAI_OS. Automates bounded local |
| 4 | +workflows while preserving the project's security and privacy posture. |
| 5 | + |
| 6 | +## Design |
| 7 | + |
| 8 | +The agent is a **supervised local autopilot**, not a free-roaming autonomous |
| 9 | +agent. It runs low-risk local tasks automatically and interrupts only at |
| 10 | +high-risk boundaries such as outbound requests, export actions, destructive |
| 11 | +operations, or trust-state changes. |
| 12 | + |
| 13 | +### Architecture (5 components) |
| 14 | + |
| 15 | +``` |
| 16 | +User Intent |
| 17 | + ↓ |
| 18 | +┌──────────┐ |
| 19 | +│ Planner │ Decomposes intent into steps (via inference worker or heuristic) |
| 20 | +└────┬─────┘ |
| 21 | + ↓ |
| 22 | +┌──────────────┐ |
| 23 | +│ Policy Engine│ Deny-by-default. Evaluates each step against capabilities, |
| 24 | +│ │ workspace scope, sensitivity labels, and session mode. |
| 25 | +└────┬─────────┘ |
| 26 | + ↓ allow / ask / deny |
| 27 | +┌──────────────┐ |
| 28 | +│ Executor │ Runs approved steps with budget enforcement. |
| 29 | +│ │ Dispatches to storage gateway, tool firewall, or airlock. |
| 30 | +└────┬─────────┘ |
| 31 | + ↓ |
| 32 | +┌──────────────┐ ┌────────────────┐ |
| 33 | +│ Storage GW │ │ Tool Firewall │ |
| 34 | +│ (file access)│ │ (:8475) │ |
| 35 | +└──────────────┘ └────────────────┘ |
| 36 | +``` |
| 37 | + |
| 38 | +### Operating modes |
| 39 | + |
| 40 | +| Mode | Network | File scope | Approval style | |
| 41 | +|------|---------|-----------|----------------| |
| 42 | +| **Offline-only** | Blocked | Approved workspaces | Auto for low-risk | |
| 43 | +| **Standard** (default) | Disabled unless enabled | Approved workspaces | Auto + ask | |
| 44 | +| **Online-assisted** | Airlock-mediated | Approved workspaces | Always ask for online | |
| 45 | +| **Sensitive** | Blocked | Explicitly scoped | Tighter budgets, aggressive recycling | |
| 46 | + |
| 47 | +### Allow / deny matrix |
| 48 | + |
| 49 | +- **Allow by default (auto)**: local search, summarize, draft, classify, report, explain security decisions |
| 50 | +- **Configurable (user preference: always / ask / never)**: file reads, file writes, tool invocations |
| 51 | +- **Hard approval required**: outbound requests, data export, trust changes, batch deletes, scope widening, new tools |
| 52 | +- **Always denied**: security setting changes |
| 53 | + |
| 54 | +## Service details |
| 55 | + |
| 56 | +| Property | Value | |
| 57 | +|----------|-------| |
| 58 | +| Port | 8476 | |
| 59 | +| Language | Python (Flask) | |
| 60 | +| Bind | 127.0.0.1 (loopback only) | |
| 61 | +| Systemd unit | `secure-ai-agent.service` | |
| 62 | +| Policy file | `/etc/secure-ai/policy/agent.yaml` | |
| 63 | +| Audit log | `/var/lib/secure-ai/logs/agent-audit.jsonl` | |
| 64 | +| Depends on | registry, tool-firewall, inference | |
| 65 | + |
| 66 | +## API endpoints |
| 67 | + |
| 68 | +| Method | Path | Description | |
| 69 | +|--------|------|-------------| |
| 70 | +| POST | `/v1/task` | Submit a new task | |
| 71 | +| GET | `/v1/task/<id>` | Get task status | |
| 72 | +| POST | `/v1/task/<id>/approve` | Approve pending steps | |
| 73 | +| POST | `/v1/task/<id>/deny` | Deny pending steps | |
| 74 | +| POST | `/v1/task/<id>/cancel` | Cancel a task | |
| 75 | +| GET | `/v1/tasks` | List tasks | |
| 76 | +| GET | `/v1/modes` | List operating modes | |
| 77 | +| GET | `/health` | Health check | |
| 78 | + |
| 79 | +## Capability tokens |
| 80 | + |
| 81 | +Every task run receives a scoped capability token defining: |
| 82 | +- **Readable paths**: which directories the agent may read |
| 83 | +- **Writable paths**: where the agent may write output |
| 84 | +- **Allowed tools**: which tools may be invoked through the tool firewall |
| 85 | +- **Online access**: whether outbound requests are even possible |
| 86 | +- **Sensitivity ceiling**: maximum data sensitivity level (low / medium / high) |
| 87 | + |
| 88 | +## Hard budgets |
| 89 | + |
| 90 | +Each task is constrained by: |
| 91 | +- Max plan steps (default: 30) |
| 92 | +- Max tool calls (default: 80) |
| 93 | +- Max tokens (default: 32,000) |
| 94 | +- Max wall-clock time (default: 600s) |
| 95 | +- Max files touched (default: 20) |
| 96 | +- Max output size (default: 1 MB) |
| 97 | + |
| 98 | +Sensitive mode uses tighter limits (10 steps, 120s, 5 files). |
| 99 | + |
| 100 | +## Storage gateway |
| 101 | + |
| 102 | +All file access goes through the storage gateway, which: |
| 103 | +- Validates paths against the capability token scope |
| 104 | +- Blocks access to sensitive system files (`/etc/shadow`, service tokens, etc.) |
| 105 | +- Classifies file sensitivity (heuristic: SSN, email, credit card, credential patterns) |
| 106 | +- Enforces sensitivity ceiling (high-sensitivity files blocked in low-ceiling sessions) |
| 107 | +- Redacts sensitive content before any outbound use |
| 108 | +- Enforces file size limits (2 MB read, 1 MB write) |
| 109 | + |
| 110 | +## Sandboxing |
| 111 | + |
| 112 | +The agent systemd service uses the same defense-in-depth as other services: |
| 113 | +- `DynamicUser=yes`, `ProtectSystem=strict`, `ProtectHome=yes` |
| 114 | +- `PrivateTmp=yes`, `PrivateDevices=yes`, `NoNewPrivileges=yes` |
| 115 | +- `MemoryDenyWriteExecute=yes`, `RestrictNamespaces=yes` |
| 116 | +- `SystemCallFilter=@system-service @network-io` |
| 117 | +- `MemoryMax=512M`, `CPUQuota=50%`, `TasksMax=64` |
| 118 | +- Read-only access to vault user docs; read-write only to outputs and logs |
| 119 | + |
| 120 | +## Implementation phases |
| 121 | + |
| 122 | +1. **Phase 1** (current): Safe local autopilot — planner, policy engine, storage gateway, tool-firewall mediation, capability tokens, automatic low-risk workflows, UI approval flow |
| 123 | +2. **Phase 2**: Security explainability — detailed explanations for quarantine/registry/airlock decisions, per-workspace permissions, sensitivity labels, audit views |
| 124 | +3. **Phase 3**: Online-assisted mode — airlock-mediated outbound, search mediation, redaction flows, approval UX for online steps |
| 125 | +4. **Phase 4**: Stronger isolation — adversarial testing, signed releases, additional sandboxing profiles, policy bypass regression tests |
0 commit comments