Skip to content

feat(sandbox): per-environment egress policy + automatic git-platform egress injection#1340

Merged
srtab merged 9 commits into
worktree-egress-policy-uifrom
git-platform-egress-injection
Jun 27, 2026
Merged

feat(sandbox): per-environment egress policy + automatic git-platform egress injection#1340
srtab merged 9 commits into
worktree-egress-policy-uifrom
git-platform-egress-injection

Conversation

@srtab

@srtab srtab commented Jun 26, 2026

Copy link
Copy Markdown
Owner

Summary

Stacked on top of the per-environment egress policy (#1336#1339; base worktree-egress-policy-ui). This PR layers automatic git-platform egress injection on that policy: network-enabled sandbox environments now reach and authenticate their own repository's git platform (GitLab/GitHub) over HTTPS without any manual host configuration.

  • DAIV injects an Authorization: Basic credential at the egress proxy, built from a short-lived, project-scoped token — the ephemeral clone token for GitLab (PAT fallback) and a contents: read installation token for GitHub — so git fetch/clone of the repository works out of the box.
  • The allow-rule is resolved per run and never stored on the environment. It is prepended so it wins by first-match over a same-host user rule, and it is hidden from the UI.
  • The reserved secret name __daiv_git_platform__ is rejected at save time, so stored config cannot silently shadow DAIV's credential.

Implementation notes

  • Shared credential shape lives in RepoClient.get_git_egress_credential (host derivation + Basic oauth2:<token> build); platform clients supply only the token via _git_egress_token.
  • apply_platform_egress / augment_sandbox_with_platform_egress merge the platform rule onto the runtime SandboxRuntime.egress at context setup, leaving the stored policy untouched.

Testing

  • uv run pytest tests/unit_tests/codebase/test_context.py tests/unit_tests/sandbox_envs/test_models.py — passes (67).
  • make lint / ruff — clean.

Review/merge order: this PR should land after its base worktree-egress-policy-ui (#1339/#1336) merges; GitHub will retarget it to main automatically once the base is merged.

srtab added 8 commits June 25, 2026 23:59
Hoist the host-derivation and `Basic oauth2:<token>` credential build into
`RepoClient.get_git_egress_credential`; GitLab/GitHub now supply only the
short-lived token via `_git_egress_token`, dropping the duplicated shape.

Reject the reserved `__daiv_git_platform__` secret name at save time, so a
stored secret/inject cannot silently shadow the runtime-injected git-platform
credential.

Also annotate `apply_platform_egress` / `augment_sandbox_with_platform_egress`,
correct the CA env-var names (`DAIV_SANDBOX_EGRESS_CA_*`) in the
egress-unavailable error, and reword the CHANGELOG credential description.
@srtab srtab self-assigned this Jun 26, 2026
Comment thread daiv/sandbox_envs/static/sandbox_envs/js/egress-editor.js Dismissed
Comment thread tests/unit_tests/sandbox_envs/test_views.py Dismissed
@srtab srtab changed the base branch from main to worktree-egress-policy-ui June 26, 2026 23:02
Merge worktree-egress-policy-ui, which drops the network_enabled flag and
attaches egress at session-create time. Resolved the conflicts by porting the
git-platform egress-injection feature onto the new model where a non-null
egress policy is what marks an env as networked.

- sandbox middleware: drop the orphaned _provision_egress; egress is now passed
  to start_session and the egress-proxy-unavailable case is handled at create
- services/context: augment_sandbox_with_platform_egress gates on egress
  presence instead of the removed network_enabled flag
- models: reconcile the egress_policy doc comment with the new model while
  keeping the git-platform injection notes
- tests: migrate SandboxRuntime construction off network_enabled and assert
  injection against the egress-presence model
@srtab srtab merged commit 077a608 into worktree-egress-policy-ui Jun 27, 2026
2 checks passed
@srtab srtab deleted the git-platform-egress-injection branch June 27, 2026 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants