Skip to content

Add --workspace-mode=direct to skip snapshot isolation#137

Merged
JAORMX merged 2 commits intomainfrom
feat/direct-workspace-mode
Apr 23, 2026
Merged

Add --workspace-mode=direct to skip snapshot isolation#137
JAORMX merged 2 commits intomainfrom
feat/direct-workspace-mode

Conversation

@JAORMX
Copy link
Copy Markdown
Contributor

@JAORMX JAORMX commented Apr 22, 2026

Summary

  • Adds --workspace-mode=<snapshot|direct> (default snapshot) and a matching workspace.mode global config key. Direct mode mounts the workspace read-write inside the VM with no COW snapshot, no diff, no review, and no git config sanitization.
  • Per-workspace .broodbox.yaml cannot enable direct mode: the merge is tighten-only (mirrors the egress and MCP authz patterns), so a repo can only force snapshot, never widen to direct. A warning is printed when a workspace config attempts it.
  • First-run --yes acknowledgement is persisted at \$XDG_STATE_HOME/broodbox/direct-mode-ack; subsequent direct-mode runs do not require the flag. A startup stderr banner prints every direct-mode run.
  • --workspace-mode=direct with --review or --exclude on the same invocation is a hard error (silent-ignore would be a data-loss footgun). review.enabled: true from global config is warned-and-ignored when direct wins.
  • --review stays exactly as it is today: still an opt-in, still meaningful in snapshot mode, no rename and no deprecation.

Safety notes

Direct mode loses: git config sanitization, worktree post-processor, hash-verified flush, sensitive-path classification, snapshot post-processors. It keeps: egress policy, credential seeding, settings injection, MCP authz. The README has a new "Workspace modes" section calling this out.

Architecture: SandboxRunner already has nil-guards on WorkspaceCloner / Reviewer / Flusher / Differ at every call site, so direct mode is wired by leaving those deps nil and setting Snapshot.Enabled=false on RunOpts. No new implementations were needed.

Test plan

  • task fmt clean
  • task lint clean
  • task test passes (added 5 merge cases + StricterWorkspaceMode, IsValidWorkspaceMode, Config.Validate, and ResolvedWorkspaceMode tests in pkg/domain/config/)
  • CLI validation smoke-tested: --workspace-mode=bogus, --workspace-mode=direct --review, --workspace-mode=direct --exclude=foo, --workspace-mode=direct without --yes all error clearly
  • Manual end-to-end run with bbox claude-code --workspace-mode=direct --yes on a throwaway workspace
  • Manual run with a .broodbox.yaml containing workspace.mode: direct to confirm the warning fires and the mode is ignored

🤖 Generated with Claude Code

Brings back the pre-d268fd2 direct-workspace path behind an opt-in
flag. Snapshot mode stays the default; direct mounts the workspace
read-write with no snapshot, no review, and no git config
sanitization, guarded by tighten-only config merge and a first-run
--yes acknowledgement persisted under XDG_STATE_HOME.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
jhrozek
jhrozek previously approved these changes Apr 22, 2026
Copy link
Copy Markdown
Contributor

@jhrozek jhrozek left a comment

Choose a reason for hiding this comment

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

LGTM. One non-blocking inline nit about ResolvedWorkspaceMode() being dead code outside its own test — either remove it or wire it in as the single source of truth for the default.

Comment thread pkg/domain/config/config.go
Delegate the empty-string normalization to the domain method instead of
inlining it in run(), making cfg.Workspace.ResolvedWorkspaceMode() the
single source of truth.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@JAORMX JAORMX merged commit 0d88c09 into main Apr 23, 2026
8 checks passed
@JAORMX JAORMX deleted the feat/direct-workspace-mode branch April 23, 2026 10:43
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