Define Windows sandbox helper contract before incremental implementation
Problem
Windows sandbox support needs an explicit contract before further implementation work.
On Windows, sandbox behavior is not equivalent to Unix-style sandboxing. Process containment, timeout cleanup, filesystem restrictions, and network restrictions are separate concerns. Without a clear contract, a Windows sandbox/helper implementation can be misunderstood as providing stronger guarantees than it actually does.
A previous PR attempted to add a Windows sandbox helper, but it touched a relatively large sandboxing surface at once. Defining the helper boundary first would make future PRs smaller and easier to review.
Proposed solution
Define an incremental Windows sandbox helper contract, starting with process containment only.
The first implementation slice should guarantee:
- Commands are launched through a dedicated Windows helper path.
- Child processes are attached to a Windows Job Object.
- The Job Object uses
JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE. - If the TUI/helper exits, or a timeout/cancel occurs, the command process tree is cleaned up.
- The behavior is covered by Windows-local tests or CI.
The first slice should explicitly not claim full sandboxing. In particular, it should not guarantee:
- ReadOnly filesystem isolation.
- WorkspaceWrite-only filesystem access.
- Denial of writes outside the workspace.
- Network blocking.
- Registry isolation.
- AppContainer-level isolation.
A possible user-facing wording could be:
Windows sandbox currently provides process-tree containment only. Filesystem and network restrictions are not enforced yet.
After that first slice is accepted, future PRs could separately explore filesystem restrictions, network restrictions, and clearer diagnostics for platform-specific sandbox guarantees.
Alternatives considered
One alternative is to implement full Windows sandboxing in a single PR. That is risky because it touches process management, filesystem policy, network policy, and user-facing sandbox semantics at the same time.
Another alternative is to leave Windows sandbox behavior unchanged. That avoids review risk, but it also leaves Windows users without clear process-tree cleanup guarantees and without clear documentation of what is or is not enforced.
A third alternative is to only update documentation. That would reduce confusion, but it would not improve timeout/cancel/TUI-exit cleanup behavior.
Additional context
The intended first PR would be small and focused:
- Add or document the Windows helper contract.
- Implement process-tree containment with a Windows Job Object.
- Add tests or manual verification for timeout/cancel cleanup.
- Avoid changing Unix sandbox behavior.
- Clearly document that filesystem and network restrictions are future work.
This would improve Windows reliability without overstating the sandbox guarantees.