refactor(craft): organize sandbox proxy modules and models (#15561)

This commit is contained in:
Wenxi authored and GitHub committed 2026-10-08 19:13:49 +00:00
1 parent 0bcb3be9f2
commit de3f09c7fd
43 files changed
+309 -282

No files matched your search

+1 -1
View File
@@ -149,7 +149,7 @@ Iterate on `sandbox_proxy/` code with the VSCode debugger attached.
4. **Provision a sandbox** via the API as you normally would, and
trigger a gated action (e.g. a Slack `chat.postMessage`). Set
breakpoints in `gate.py`, `addons/gate.py`, `identity_docker.py`,
breakpoints in `gate.py`, `addons/gate.py`, `sandbox_identity/docker.py`,
etc.
## Smoke-check commands
@@ -20,15 +20,16 @@ The short version:
Proxy runtime:
- `backend/onyx/sandbox_proxy/models.py` defines shared destination, credential
injection, and MCP classification models.
- `backend/onyx/sandbox_proxy/server.py` starts mitmproxy, health checks, CA
bootstrap, identity lookup, request evaluator, credential resolvers, and the
gate addon.
- `backend/onyx/sandbox_proxy/addons/gate.py` owns request classification,
approval parking, grant resolution, credential injection dispatch, internal
destination blocking, and SIGTERM drain cleanup.
- `backend/onyx/sandbox_proxy/identity.py`,
`identity_k8s.py`, and `identity_docker.py` resolve source IPs to sandbox,
tenant, and user identity.
- `backend/onyx/sandbox_proxy/sandbox_identity/` modules resolve source IPs to sandbox,
tenant, and user identity. Its `models.py` defines the identity and session models.
- `backend/onyx/sandbox_proxy/request_evaluator.py` turns mitmproxy requests
into external-app action matches.
- `backend/onyx/sandbox_proxy/credential_injection.py` and
@@ -36,7 +37,7 @@ Proxy runtime:
and external-app credentials.
- `backend/onyx/sandbox_proxy/approval_cache.py` defines Redis announce, wake,
and session-grant cache keys.
- `backend/onyx/sandbox_proxy/ca.py`, `ca_k8s.py`, and `ca_docker.py` manage
- `backend/onyx/sandbox_proxy/certificate_authority/` modules manage
the proxy CA.
Approval persistence and API:
@@ -43,7 +43,7 @@ Constraints from the existing code that shape the design:
actions with a stored `external_app_policy` row reach the matcher at
all; "gated" means a stored row with `ASK`.
- **`SessionContext` does not carry `origin`** —
`resolve_session_by_id` (`sandbox_proxy/identity.py`) selects only
`resolve_session_by_id` (`sandbox_proxy/sandbox_identity/resolution.py`) selects only
`BuildSession.id`. The short-circuit needs one new joined lookup:
`BuildSession → ScheduledTaskRun (session_id FK) → ScheduledTask`;
grants come along with the task row.