Skip to content

SuperInstance/branch-sandbox

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

branch-sandbox — Isolated Branch Execution

Sandboxed branches of mutable state. Run code in isolation, compare outputs, merge results — all without affecting the main environment.

What This Gives You

  • Sandboxed branches — create isolated copies of state for safe experimentation
  • Branch execution — run code inside a branch without affecting the main state
  • Diff comparison — compare branch outputs against the main environment
  • Smart merging — merge branch results back with conflict detection and resolution
  • Status tracking — CREATED → ACTIVE → COMPLETED → MERGED / ABORTED lifecycle

Quick Start

pip install branch-sandbox
from branch_sandbox import Sandbox, SandboxConfig, Branch, MergeEngine

# Create a sandbox
sandbox = Sandbox(config=SandboxConfig(base_state={"counter": 0, "data": []}))

# Create a branch for experimentation
branch = sandbox.create_branch("experiment-1")

# Execute in isolation
result = sandbox.execute(branch, lambda state: {**state, "counter": state["counter"] + 1})
print(branch.status)  # ACTIVE

# Compare with main
comparison = sandbox.compare(branch)
print(comparison.diff)  # {"counter": {"main": 0, "branch": 1}}

# Merge back
merge = MergeEngine()
result = merge.merge(sandbox.main, branch)
print(result.status)  # MERGED

API Reference

Sandbox(config)create_branch(name), execute(branch, fn), compare(branch)

SandboxConfig(base_state, max_branches=None)

Branch(name, status=CREATED) · BranchStatus — CREATED, ACTIVE, COMPLETED, MERGED, ABORTED

SandboxExecutor — Execute functions inside branch context

BranchComparison / DiffRecord — Side-by-side state comparison

MergeEnginemerge(main, branch) → MergeResult with conflict detection

How It Fits

The isolation layer for the SuperInstance fleet. Agents experiment in sandboxes before committing changes to production.

Testing

pytest tests/

Installation

pip install branch-sandbox

Python 3.10+. MIT license.

About

Isolated branch environments for testing vessel mutations safely

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 100.0%