Skip to content

fix(windows): resolve sandbox binary execution, flaky file renames, and plan mode - #638

Closed
euxaristia wants to merge 1 commit into
Gitlawb:mainfrom
euxaristia:fix/windows-sandbox-and-plan-mode
Closed

fix(windows): resolve sandbox binary execution, flaky file renames, and plan mode#638
euxaristia wants to merge 1 commit into
Gitlawb:mainfrom
euxaristia:fix/windows-sandbox-and-plan-mode

Conversation

@euxaristia

@euxaristia euxaristia commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

This PR fixes Windows-specific sandbox and execution failures. Specifically:

  1. Adds WinBuiltinUsersSid and WinAuthenticatedUserSid to the Windows restricted token's restricted SIDs list so that toolchains like Go can be read/executed from system directories.
  2. Introduces renameWithRetry to prevent transient Access is denied errors under Windows during atomic file renames in cron, sessions, swarm, and sandbox.
  3. Fixes TUI plan command compilation and logic (migrated editor spawn to tea.ExecProcess, corrected signature check of planmode.PlanFilePath, and prints plan when plan mode is toggled ON).

Summary by CodeRabbit

  • New Features

    • Added a read-only planning mode with restricted tool access.
    • Added /plan open to edit the session plan using the configured editor.
    • Plan views now display saved plan-file content when available.
  • Bug Fixes

    • Improved reliability of file updates during transient Windows rename and sharing conflicts.
    • Strengthened Windows sandbox restrictions.
    • Improved diagnostics for concurrent mailbox send failures.

@euxaristia euxaristia closed this Jul 10, 2026
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 26620b41-798e-4622-ace0-ea9db5a609e8

📥 Commits

Reviewing files that changed from the base of the PR and between 1af5882 and 30c3227.

📒 Files selected for processing (11)
  • internal/agent/loop.go
  • internal/agent/types.go
  • internal/cron/store.go
  • internal/sandbox/windows_token_windows.go
  • internal/sandbox/windows_unelevated.go
  • internal/sessions/store.go
  • internal/swarm/mailbox.go
  • internal/swarm/mailbox_test.go
  • internal/tui/model.go
  • internal/tui/plan_command.go
  • internal/tui/run.go

Walkthrough

Adds a read-only plan permission mode with TUI plan-file editing, retries atomic renames on transient Windows failures across persistence paths, and includes additional built-in SIDs in Windows restricted tokens.

Changes

Plan mode

Layer / File(s) Summary
Plan permission contract and tool gating
internal/agent/types.go, internal/agent/loop.go
Adds PermissionModePlan, exposes only read-safe planning tools, and returns mode-specific unavailable-tool errors.
Plan commands and editor flow
internal/tui/model.go, internal/tui/plan_command.go, internal/tui/run.go
Routes /plan commands through plan-file display and $VISUAL/$EDITOR integration, with Bubble Tea suspension and resume support.

Atomic rename retries

Layer / File(s) Summary
Cron metadata rename retry
internal/cron/store.go
Retries metadata replacement and detects Windows sharing violations.
Session and mailbox atomic writes
internal/sessions/store.go, internal/swarm/mailbox.go, internal/swarm/mailbox_test.go
Applies bounded retry handling to session and mailbox atomic writes and logs concurrent send errors.
Unelevated marker replacement
internal/sandbox/windows_unelevated.go
Retries Windows marker replacement for permission and sharing-violation failures.

Windows restricted token

Layer / File(s) Summary
Restricted token SID entries
internal/sandbox/windows_token_windows.go
Adds users and authenticated-user SIDs to restricted token entries.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant TUI
  participant PlanFile
  participant Editor
  User->>TUI: /plan open
  TUI->>PlanFile: resolve and create plan file
  TUI->>Editor: launch editor
  Editor->>PlanFile: write plan
  TUI->>PlanFile: read current plan
  TUI->>User: render plan
Loading

Possibly related PRs

  • Gitlawb/zero#60: Related to permission-mode tool advertisement filtering in internal/agent/loop.go.
  • Gitlawb/zero#158: Related to /plan command handling in internal/tui/model.go.
  • Gitlawb/zero#612: Related to restricted-token behavior in internal/sandbox/windows_token_windows.go.

Suggested reviewers: gnanam1990, kevincodex1, anandh8x, Vasanthdev2004

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant