Skip to main content
Fork creates a child sandbox from the parent’s live machine state. Parent and child continue as independent running sandboxes, so each can mutate files, processes, and services without changing the other branch. Use reusable snapshots when the captured state should be durable and restored many times later.

What state changes

  • A new child sandbox starts from the parent’s current state.
  • Parent and child receive separate sandbox IDs and routing credentials.
  • Later filesystem and process changes diverge between the two sandboxes.

Usage

from nullspace import Sandbox

with Sandbox.create() as parent:
    parent.files.write("/workspace/state.txt", "base\n")
    child = parent.fork()
    try:
        child.files.write("/workspace/state.txt", "child\n")
        print(parent.files.read("/workspace/state.txt").strip())
        print(child.files.read("/workspace/state.txt").strip())
    finally:
        child.kill()
API reference: forkSandbox (POST /v1/sandboxes/{id}/fork). Guide: Sandbox lifecycle. Example: Examples.