Skip to content

feat(threads): add managed sandbox profiles - #1114

Merged
nixuuu merged 3 commits into
devfrom
feat/sandbox-profiles
Nov 22, 2026
Merged

nixuuu merged 3 commits into
devfrom
feat/sandbox-profiles

Conversation

@nixuuu

@nixuuu nixuuu commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Change

Owners can manage sandbox profiles in Settings → Threads and choose them for threads and scheduled tasks. The composer shows Sandbox - [Profile]. Unavailable choices share a short explanation by cause. The existing permission mode retains its wire value and its original behavior under Harness default. For a linked computer, the picker directs owners to Canopy on that computer for a new selection from its catalog.

A named profile applies to sandboxed commands and their descendants. An empty domain list blocks outbound connections. A populated list restricts connections to the exact hostnames. Threads, scheduled tasks, and synced drafts retain the selected policy across resume, retry, and reload. Gateway and worker check the selection before execution. Database guards prevent older gateways from discarding a persisted policy. Consolidation requires the updated schema on both gateways and carries the stored policy and historical command digests.

Thanks @mikuyeyu for reporting the original Codex sandbox behavior.

Runtime support

  • Codex 0.171.0 on a qualified Linux worker with a custom API instance and no linked Codex login supports offline profiles. Exact-domain selection stays unavailable because ordinary Codex rules can expand the list.
  • Claude Code 2.1.316 and 2.1.330 on a qualified Linux worker with Bubblewrap, socat, and a custom API instance supports offline and exact-domain profiles. Canopy refuses a launch if it cannot verify that the requested profile preserves the applicable policy.
  • Named profiles are unavailable for native Windows, macOS, and Grok in this implementation. WSL2 requires a worker and CLI inside Linux with a functioning sandbox. Native Windows and WSL2 were not exercised.

Verification

  • Ran 86 focused tests on the thread worker. Coverage includes PostgreSQL migration guards, consolidation, gateway and worker transport, scheduling, synced drafts, linked routing, and both adapters. Scoped lint and affected application typechecks passed.
  • Ran native CLI probes through WorkerHost in an isolated Ubuntu KVM guest on the same worker, using a synthetic inference endpoint and HTTP origin. Codex offline and both Claude versions blocked denied traffic, emitted no approval requests, allowed workspace writes, and denied outside writes. The two Claude versions reached only the permitted host when assigned a domain profile.
  • Exercised Settings, profile selection, draft restore and explicit clear, and scheduled-task creation in the app's shared web/desktop renderer. Checked 420 px width and a maximum-length profile name. The control retained the full accessible name and the page had no horizontal overflow. Mobile typecheck passed. Native mobile rendering was not exercised.

Copy audit

Full auto → Sandbox for the permission mode. The selected profile is visible on the closed control. One-line mode rows retain the permission cues, longer descriptions are under Show permission details, and unavailable profiles share their reason. Checked sentence case, action labels, glossary terms, errors and recovery actions, wrapping and truncation, linked-computer guidance, and accessible names. Status cues use text in addition to styling.

@nixuuu
nixuuu enabled auto-merge (squash) November 22, 2026 15:41
@nixuuu
nixuuu disabled auto-merge November 22, 2026 15:42
@nixuuu
nixuuu enabled auto-merge (squash) November 22, 2026 15:44
@nixuuu
nixuuu disabled auto-merge November 22, 2026 15:54
@nixuuu
nixuuu enabled auto-merge (squash) November 22, 2026 15:58
@nixuuu
nixuuu merged commit 27537c8 into dev Nov 22, 2026
17 checks passed
@nixuuu
nixuuu deleted the feat/sandbox-profiles branch November 22, 2026 16:05
nixuuu added a commit that referenced this pull request Nov 26, 2026
## Changes

- Preserve the directory entry when resolving a Codex login. On macOS,
Bun can return the path of another hard link to the same inode during
concurrent lookups. Bot migration now detaches the managed link while
protecting the source login, including a source reached through a
symbolic link.
- Lock the thread before marking `StartTurn` and `SteerTurn` as
delivered. This matches archival and prevents the sandbox profile
trigger from deadlocking against command expiry.
- Wait for the gateway's persisted turn context in the linked-agent
fixture. Give the Tailscale and Windows Codex fixtures separate process
and test budgets with useful failure diagnostics. Run one native
packaging test per macOS architecture and log the slow `actool` and
Swift phases.
- Retry failed Release jobs once for a scheduled nightly when GitHub
annotated each failed job with a hosted runner disconnect or an
exhausted `CreateArtifact` request timeout. The retry uses the same run
and revision and preserves the existing Push CI and publication gates.

## Verification

- Bun 1.4.5 on Apple Silicon passed 24 Codex migration and bot login
tests and 12 desktop packaging tests through `check:tmp`. A
50,000-iteration race reproduced 23,655 missed links with the previous
lookup and zero after the fix.
- PostgreSQL 18 reproduced `40P01` with the old outbox lock order. The
regression passed five repetitions after the fix. All 31 targeted
archive, linked-agent and sandbox integration tests passed.
- Tailscale passed 60 repeated executions. Both pinned Codex versions
passed the live login fixture on macOS. Codex 0.172.0 also passed with
an injected 24-second credential probe startup delay.
- Worker and integration typechecks, focused lint and formatting,
`actionlint`, and `git diff --check` passed. Tested the recovery script
with real historical GitHub job data and a stubbed POST for runner loss,
the `CreateArtifact` timeout that blocked
[v0.11.0-nightly.1](https://github.com/itsoltech/canopy/actions/runs/45770577786/attempts/1),
an ordinary CI failure, and a prior rerun.
- GitHub CI covers the native Windows and macOS Intel changes. Live
recovery requires a future scheduled Release with one of the recognized
GitHub infrastructure failures.

Fixes: #1213
Fixes: #1114
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