Skip to content

Add pluggable notebook sandbox backends - #10697

Draft
manzt wants to merge 2 commits into
sandbox-packagesfrom
sandbox-pixi
Draft

Add pluggable notebook sandbox backends#10697
manzt wants to merge 2 commits into
sandbox-packagesfrom
sandbox-pixi

Conversation

@manzt

@manzt manzt commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Sandboxing is specialized to uv: session code invokes uv directly, so a second environment manager has nothing to plug into.

This PR introduces NotebookSandbox, the session-owned interface to one notebook's environment manager, with uv and pixi adapters behind it. --sandbox=pixi selects pixi (prefix-dev/pixi#6648); --sandbox and --sandbox=uv remain equivalent. Mutations edit the manifest and synchronize as one operation, and package inspection stays read-only.

class NotebookSandbox:
    def launch(self, args, *, overlay=()) -> ProcessPlan: ...
    def add(self, package, *, upgrade=False) -> EnvironmentChange: ...
    def remove(self, package) -> EnvironmentChange: ...
    def packages(self) -> PackageState: ...
    def rebind(self, source) -> None: ...

Bare requirements are pinned to the version the environment resolved, so a shared notebook reproduces its environment without a lockfile. The package panel shows the sandbox's manifest and resolved tree.

@vercel

vercel Bot commented Aug 28, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview Aug 28, 2026 10:59pm

Request Review

@github-actions github-actions Bot added the bash-focus Area to focus on during release bug bash label Aug 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@manzt manzt added the enhancement New feature or request label Aug 28, 2026
@manzt manzt changed the title sandbox pixi Add pluggable notebook sandbox backends Aug 28, 2026
@github-actions

github-actions Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for ./frontend

Status Category Percentage Covered / Total
🔵 Lines 56.38% 21036 / 37307
🔵 Statements 56.29% 21402 / 38017
🔵 Functions 49.22% 4715 / 9579
🔵 Branches 49.81% 10849 / 21779
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
frontend/src/__mocks__/requests.ts 100% 100% 100% 100%
frontend/src/components/editor/chrome/panels/packages-panel.tsx 58.33% 65.78% 52.94% 59.15% 54, 107, 145-157, 212-214, 220-221, 225-229, 270-275, 366-402, 428, 432-447, 467-481, 507, 511-516, 534, 585-588, 653-686, 734, 739
frontend/src/core/wasm/bridge.ts 28.07% 30.61% 17.14% 28.18% 212-225, 254-386, 397-534, 558-663, 666-672, 100, 120, 133-135, 141-151, 154-190, 198-199, 208-224, 229-230, 236, 242, 255-385, 390-391, 398-533, 561-703
Generated in workflow #20882 for commit 27ab388 by the Vitest Coverage Report Action

manzt added 2 commits August 28, 2026 18:55
NotebookSandbox owns one notebook manifest and environment lifecycle. Mutations edit and synchronize as one operation, package inspection stays read-only, and rebinding defers environment work until the next launch or mutation.

Backend adapters keep uv and pixi command paths independent, so sandbox=pixi requires only pixi and sandbox=uv requires only uv. SINGLE and MULTI remain process topologies that route through the same session-owned interface.

A bare requirement added through the panel is pinned to the version the synchronized environment resolved, so a shared notebook reproduces its environment without a lockfile. An upgrade reopens the pin so the solve can advance.

The module-level launch verbs dispatch through the same adapters, so backend policy lives in the adapter alone, and the runners report the exact argv they execute. Failures from either manager derive from `EnvironmentManagerError`, and backend-agnostic callers catch one error.
The package panel previously inferred sandbox mode from a synthetic tree
root, so it could not identify the selected backend or distinguish a
managed script environment from a configurable package manager.

Carry the effective installation context with the dependency tree.
Sandbox sessions expose a fixed Pixi or uv manifest tree, while regular
sessions retain list and tree views and a configurable package manager.

Use native tree output from each backend and mark repeated subtrees as
deduplicated instead of cycles. Pixi trees are filtered to PyPI packages
so Conda implementation details do not leak into the notebook manifest.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bash-focus Area to focus on during release bug bash enhancement New feature or request team-draft

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant