Skip to content

refactor(sandbox): remove OS-level write restrictions, shift to permission-gated model#101

Merged
yishuiliunian merged 2 commits intomainfrom
worktree-parallel-coalescing-backus
Apr 15, 2026
Merged

refactor(sandbox): remove OS-level write restrictions, shift to permission-gated model#101
yishuiliunian merged 2 commits intomainfrom
worktree-parallel-coalescing-backus

Conversation

@yishuiliunian
Copy link
Copy Markdown
Contributor

Summary

  • OS sandbox (seatbelt/bwrap) no longer restricts file writes in DefaultWrite mode — eliminates hard-block failures for CLI tools that write to $HOME config dirs (lark-cli, npm, cargo, etc.)
  • File tools retain fine-grained protection via app-level path_checker + deny_write_globs (soft deny with approval flow)
  • Bash commands are gated by the permission system (user/classifier approval), not the OS sandbox

Changes

  • platform/macos.rs: WorkspaceWrite seatbelt profile → (allow file-write*) instead of per-path rules
  • platform/linux.rs: WorkspaceWrite bwrap → --bind / / (rw root) instead of --ro-bind + per-path binds
  • sandbox.rs (config): Rename WorkspaceWriteDefaultWrite with serde(alias) for backward compat
  • policy.rs: Add $HOME to baseline writable_paths (app-level path_checker only)
  • sensitive_patterns.rs: Add deny_write_globs for shell configs (.bashrc/.zshrc), authorized_keys, LaunchAgents/LaunchDaemons
  • env_patterns.rs (new): Extract env variable patterns from sensitive_patterns (200-line limit)
  • permission.rs: Fix stale "Sandbox still blocks" comment on Bypass mode
  • seatbelt_base.sbpl, README.md: Update stale references to old model

Test plan

  • bazel test //crates/loopal-sandbox:loopal-sandbox_test passes
  • bazel test //crates/loopal-backend:loopal-backend_test passes
  • bazel build //... --config=clippy zero warnings
  • CI passes

…ssion-gated model

The seatbelt/bwrap file-write restrictions added no real security for
Bash commands (process-exec was already unrestricted) but broke every
CLI tool that writes to $HOME config dirs (lark-cli, npm, cargo, etc.).

DefaultWrite mode now allows all file writes at the OS level.  File
tools keep fine-grained protection via app-level path_checker +
deny_write_globs (RequiresApproval → user approval).  Bash commands
are gated solely by the permission system.

- Rename WorkspaceWrite → DefaultWrite (serde alias for compat)
- Add $HOME to baseline writable_paths (app-level path_checker)
- Add deny_write_globs for shell configs, authorized_keys, LaunchAgents
- Extract env patterns to env_patterns.rs (200-line limit)
- Fix stale comments across permission.rs, seatbelt_base.sbpl, README
@yishuiliunian yishuiliunian merged commit 2db7d0e into main Apr 15, 2026
4 checks passed
@yishuiliunian yishuiliunian deleted the worktree-parallel-coalescing-backus branch April 15, 2026 06:06
yishuiliunian added a commit that referenced this pull request Apr 15, 2026
Background tasks were invisible in the TUI because the agent process
and TUI process had separate BackgroundTaskStore instances (noted as
"future: sync from agent via IPC" in multiprocess.rs).

Replace the polling-based reporter with event-driven sync matching the
ToolProgress pattern:

- BackgroundTaskStore emits SpawnNotification on insert, carrying Arc
  handles for per-task monitoring
- bg_task_bridge subscribes and spawns per-task select! monitors:
  output sampler (2s delta) + completion watcher (await watch_rx)
- Three protocol events: BgTaskSpawned, BgTaskOutput, BgTaskCompleted
- Session state builds incrementally from events (IndexMap for O(1))
- TUI reads from session state; panel shows all tasks; Enter opens
  full-screen log viewer SubPage with auto-follow

Removes TUI dependency on loopal-tool-background (bg_store was always
empty in the TUI process).
yishuiliunian added a commit that referenced this pull request Apr 15, 2026
Background tasks were invisible in the TUI because the agent process
and TUI process had separate BackgroundTaskStore instances (noted as
"future: sync from agent via IPC" in multiprocess.rs).

Replace the polling-based reporter with event-driven sync matching the
ToolProgress pattern:

- BackgroundTaskStore emits SpawnNotification on insert, carrying Arc
  handles for per-task monitoring
- bg_task_bridge subscribes and spawns per-task select! monitors:
  output sampler (2s delta) + completion watcher (await watch_rx)
- Three protocol events: BgTaskSpawned, BgTaskOutput, BgTaskCompleted
- Session state builds incrementally from events (IndexMap for O(1))
- TUI reads from session state; panel shows all tasks; Enter opens
  full-screen log viewer SubPage with auto-follow

Removes TUI dependency on loopal-tool-background (bg_store was always
empty in the TUI process).
yishuiliunian added a commit that referenced this pull request Apr 15, 2026
* feat(tui): event-driven background task sync and log viewer (#101)

Background tasks were invisible in the TUI because the agent process
and TUI process had separate BackgroundTaskStore instances (noted as
"future: sync from agent via IPC" in multiprocess.rs).

Replace the polling-based reporter with event-driven sync matching the
ToolProgress pattern:

- BackgroundTaskStore emits SpawnNotification on insert, carrying Arc
  handles for per-task monitoring
- bg_task_bridge subscribes and spawns per-task select! monitors:
  output sampler (2s delta) + completion watcher (await watch_rx)
- Three protocol events: BgTaskSpawned, BgTaskOutput, BgTaskCompleted
- Session state builds incrementally from events (IndexMap for O(1))
- TUI reads from session state; panel shows all tasks; Enter opens
  full-screen log viewer SubPage with auto-follow

Removes TUI dependency on loopal-tool-background (bg_store was always
empty in the TUI process).

* fix: rustfmt formatting in new test and source files
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