Skip to content

sandboxes: document branch-mode in-container clone and source-repo isolation#25007

Closed
ndeloof wants to merge 1 commit into
docker:mainfrom
ndeloof:ndeloof/sandboxes-branch-clone-docs
Closed

sandboxes: document branch-mode in-container clone and source-repo isolation#25007
ndeloof wants to merge 1 commit into
docker:mainfrom
ndeloof:ndeloof/sandboxes-branch-clone-docs

Conversation

@ndeloof
Copy link
Copy Markdown
Contributor

@ndeloof ndeloof commented May 8, 2026

Summary

Documents the branch-mode rework introduced in docker/sandboxes#2477, which replaces on-host Git worktrees with an in-container clone exposed over git-daemon, and surfaces the new source-repository isolation guarantee.

User-facing changes in usage.md:

  • Rewrites the Branch mode section to describe the in-container clone, the read-only source mount, and the sandbox-<name> Git remote that gets wired on the host.
  • Replaces the worktree-walking workflow (git worktree list, cd .sbx/...) with the simpler git fetch sandbox-<name> review flow.
  • Drops the now-obsolete .sbx/-directory and "multiple branches per sandbox" sections.
  • Adds a Restrictions section covering the configurations rejected at create time (--workspace-volume, host worktree).

Security-model changes:

  • Adds a new Source-repository isolation section in security/isolation.md that explains why the agent — even running unconstrained — cannot corrupt the host's .git state. The host source is bind-mounted read-only at /run/sandbox/source; the agent's clone is private (own index, own refs, own working tree) and shares only the immutable object database via .git/objects/info/alternates.
  • Promotes the security model from four to five isolation layers in security/_index.md.
  • Updates security/workspace.md to correct the previous "branch mode is a workflow convenience, not a security boundary" caveat, which is no longer accurate after added compose file example in accordion #2477.

The changes lean heavily on the threat-model framing the user asked for: the new design is not just ergonomic, it is the first time --branch provides a hard isolation boundary for the source repository.

Dependency

This documentation describes behavior introduced by docker/sandboxes#2477, which is not yet merged at the time of opening this PR. Please hold this PR or land it on the next sandboxes release that ships #2477.

Test plan

  • Visual review of the rendered usage.md branch-mode section
  • Visual review of the rendered security/isolation.md source-repository-isolation section
  • Cross-link sanity check between usage.md, security/workspace.md, and security/isolation.md

@netlify
Copy link
Copy Markdown

netlify Bot commented May 8, 2026

Deploy Preview for docsdocker ready!

Name Link
🔨 Latest commit 6b0aed9
🔍 Latest deploy log https://app.netlify.com/projects/docsdocker/deploys/6a0b7956c6d6720008a55eee
😎 Deploy Preview https://deploy-preview-25007--docsdocker.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Copy Markdown

@docker-agent docker-agent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

The documentation changes are well-written and follow Docker's style guidelines. The branch-mode section rewrite, source-repository isolation explanation, and security model updates are clear, accurate, and appropriately scoped.

@ndeloof ndeloof force-pushed the ndeloof/sandboxes-branch-clone-docs branch from 17a22ac to 5c7b0f7 Compare May 18, 2026 15:52
@ndeloof ndeloof marked this pull request as ready for review May 18, 2026 16:04
@ndeloof ndeloof requested a review from dvdksn as a code owner May 18, 2026 16:04
Copy link
Copy Markdown

@docker-agent docker-agent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟡 NEEDS ATTENTION

Comment thread content/manuals/ai/sandboxes/usage.md Outdated
Comment thread content/manuals/ai/sandboxes/security/isolation.md Outdated
Comment thread content/manuals/ai/sandboxes/usage.md Outdated
Comment thread content/manuals/ai/sandboxes/security/workspace.md Outdated
Copy link
Copy Markdown

@docker-agent docker-agent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

The PR is well-structured and clearly documents the branch-mode in-container clone and source-repository isolation. Content is accurate and the technical explanations are thorough. A few minor style guide violations in the added content.

Comment thread content/manuals/ai/sandboxes/usage.md Outdated
Comment thread content/manuals/ai/sandboxes/security/workspace.md Outdated
Comment thread content/manuals/ai/sandboxes/security/isolation.md Outdated
…olation

Update the branch-mode workflow to reflect the move from on-host worktrees
to an in-container clone exposed over git-daemon, and add a new
source-repository isolation layer to the security model. Highlights the
strong guarantee that an unconstrained agent cannot corrupt the host's
.git directory or working tree, since the source mount is read-only and
the agent operates on a private clone with its own index, refs, and
working tree.

Tracks docker/sandboxes#2477.
@ndeloof ndeloof force-pushed the ndeloof/sandboxes-branch-clone-docs branch from 5c7b0f7 to 6b0aed9 Compare May 18, 2026 20:40
dvdksn pushed a commit to ndeloof/docker.github.io that referenced this pull request May 26, 2026
… isolation

Replaces the `--branch[=NAME]` documentation with `--clone` (boolean) on
both `sbx create` and `sbx run`, matching the CLI rename in docker/sandboxes#3055.
Clone mode is now strictly about running the agent on a private in-container
`git clone --reference` of the host repository; no host-side branch is
created on the user's behalf — the user instructs the agent to
`git checkout -b ...` inside the sandbox if a dedicated working branch is
needed.

Key documentation changes:

- usage.md: "Branch mode" section is renamed to "Clone mode" and rewritten
  end-to-end. Drops the `.sbx/<name>-worktrees/...` directory mention (no
  longer created), the host-side branch creation/checkout step, the
  `--branch=auto` flow, and the legacy "Multiple branches per sandbox"
  section. Adds:
    * an explicit note that clone mode is fixed at create time;
    * the forge-remote propagation behaviour (origin/upstream propagated
      from host into the in-container clone, local-path remotes skipped);
    * a Cleanup warning about lost in-container commits when running
      `sbx rm` (mirrors the runtime warning).
- security/isolation.md: adds the "Source-repository isolation" section
  introduced in docker#25007. Same content, but uses `--clone` and "clone mode"
  terminology throughout, plus a clarifying note that `sbx rm` warns
  before dropping unfetched/unpushed commits.
- security/workspace.md: the existing "Branch mode" stub (claiming the old
  `--branch` was a "workflow convenience, not a security boundary") is
  replaced with a "Clone mode" section that explicitly calls out the
  isolation guarantee — clone mode IS a security boundary, the host's
  `.git` cannot be touched.
- security/_index.md: source-repository isolation is added to the
  five-layer model (was four). Wording aligned with isolation.md.

Migration: callers that scripted `sbx create --branch=feature/x` now pass
`--clone` and tell the agent to create the branch.

This PR is an alternative to docker#25007, written against the
post-rename CLI.

Signed-off-by: Nicolas De loof <nicolas.deloof@gmail.com>
@ndeloof ndeloof closed this May 27, 2026
dvdksn pushed a commit to ndeloof/docker.github.io that referenced this pull request May 27, 2026
… isolation

Replaces the `--branch[=NAME]` documentation with `--clone` (boolean) on
both `sbx create` and `sbx run`, matching the CLI rename in docker/sandboxes#3055.
Clone mode is now strictly about running the agent on a private in-container
`git clone --reference` of the host repository; no host-side branch is
created on the user's behalf — the user instructs the agent to
`git checkout -b ...` inside the sandbox if a dedicated working branch is
needed.

Key documentation changes:

- usage.md: "Branch mode" section is renamed to "Clone mode" and rewritten
  end-to-end. Drops the `.sbx/<name>-worktrees/...` directory mention (no
  longer created), the host-side branch creation/checkout step, the
  `--branch=auto` flow, and the legacy "Multiple branches per sandbox"
  section. Adds:
    * an explicit note that clone mode is fixed at create time;
    * the forge-remote propagation behaviour (origin/upstream propagated
      from host into the in-container clone, local-path remotes skipped);
    * a Cleanup warning about lost in-container commits when running
      `sbx rm` (mirrors the runtime warning).
- security/isolation.md: adds the "Source-repository isolation" section
  introduced in docker#25007. Same content, but uses `--clone` and "clone mode"
  terminology throughout, plus a clarifying note that `sbx rm` warns
  before dropping unfetched/unpushed commits.
- security/workspace.md: the existing "Branch mode" stub (claiming the old
  `--branch` was a "workflow convenience, not a security boundary") is
  replaced with a "Clone mode" section that explicitly calls out the
  isolation guarantee — clone mode IS a security boundary, the host's
  `.git` cannot be touched.
- security/_index.md: source-repository isolation is added to the
  five-layer model (was four). Wording aligned with isolation.md.

Migration: callers that scripted `sbx create --branch=feature/x` now pass
`--clone` and tell the agent to create the branch.

This PR is an alternative to docker#25007, written against the
post-rename CLI.

Signed-off-by: Nicolas De loof <nicolas.deloof@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants