Skip to content

feat(sandbox): sandbox service#105

Open
yyquiet wants to merge 6 commits intoxorbitsai:mainfrom
yyquiet:feature/sandbox
Open

feat(sandbox): sandbox service#105
yyquiet wants to merge 6 commits intoxorbitsai:mainfrom
yyquiet:feature/sandbox

Conversation

@yyquiet
Copy link
Contributor

@yyquiet yyquiet commented Mar 6, 2026

Add abstract base classes for sandbox lifecycle management:

  • Sandbox: Interface for sandbox instance operations
  • SandboxService: Interface for sandbox lifecycle management
  • Support for template-based creation (image/snapshot)
  • File operations (upload/download/read/write)
  • Code execution (Python/JavaScript)
  • Snapshot management

Add implementation based on BoxLite.

@qinxuye
Copy link
Contributor

qinxuye commented Mar 8, 2026

I am OK with this, @rogercloud could give a review.

@qinxuye
Copy link
Contributor

qinxuye commented Mar 9, 2026

if any implementation is introduced, this PR title might need to be modified.

@yyquiet yyquiet changed the title feat(sandbox): abstract interface for sandbox service feat(sandbox): sandbox service Mar 9, 2026
liyuan added 6 commits March 9, 2026 21:34
Add abstract base classes for sandbox lifecycle management:
- Sandbox: Interface for sandbox instance operations
- SandboxService: Interface for sandbox lifecycle management
- Support for template-based creation (image/snapshot)
- File operations (upload/download/read/write)
- Code execution (Python/JavaScript)
- Snapshot management
@qinxuye qinxuye mentioned this pull request Mar 11, 2026
69 tasks
rogercloud

This comment was marked as abuse.

Copy link
Collaborator

@rogercloud rogercloud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sandbox feature code review. Found 9 issues (see inline comments).

Summary:

  • Style: 3 (naming, shadowing, redundant imports)
  • Minor: 3 (redundant imports)
  • Design: 2 (private access, snapshot interface)
  • UX: 1 (silent exception)
  • Validation: 1 (input validation)

Overall: Code is fundamentally sound and ready to merge. All issues are minor.



@dataclass
class SandBoxTemplate:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue #1: Naming Inconsistency

SandBoxTemplate uses SandBox (two words, capital B) but the module is sandbox (one word, lowercase). Suggestion: Rename to SandboxTemplate.

# First copy to temp directory (if copying directly to mount directory, it won't be readable on host)
# Note: Cannot use /tmp as it's a tmpfs mount, copy_in will fail
# Use /var/tmp or other non-tmpfs directory
import uuid
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue #2: Redundant import uuid at line 231 - already imported at module level (line 12).

raise FileExistsError(f"Local file already exists: {local_path}")

# First copy to temp directory (avoid volume mount issues)
import uuid
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue #3: Redundant import uuid at line 273 - already imported at module level (line 12).

"""Get sandbox status information."""
try:
# Update state in real-time
box_info = await self._box._runtime.get_info(self._name)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue #4: Private member access _box._runtime violates encapsulation. Add comment explaining why or request public API.

# Update state in real-time
box_info = await self._box._runtime.get_info(self._name)
self._info.state = _get_state(box_info)
except Exception as e:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue #5: Silent exception handling - returns cached info without indicating it might be stale.

Configuration parameters for creating a sandbox.
"""

cpus: Optional[int] = 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue #6: Missing input validation for cpus and memory. Add post_init validation.

@pytest.mark.asyncio(loop_scope="module")
async def test_list_sandboxes(self):
"""Test listing sandboxes"""
list = ["test-list-1", "test-list-2"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue #7: Variable list shadows built-in. Rename to sandbox_names.

# Create sandbox
template = SandBoxTemplate(_type="image", image="python:slim")

import tempfile
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue #8: Redundant import tempfile - already imported at line 9.

"""


class SandboxService(abc.ABC):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue #9: No interface to check snapshot support. Add supports_snapshots property to SandboxService interface.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants