Fork creates a child machine from the parent’s live machine state. Parent and child continue as independent running machines, 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 machine starts from the parent’s current state.
  • Parent and child receive separate machine IDs and routing credentials.
  • Later filesystem and process changes diverge between the two machines.

Usage

from nullspace import Machine

with Machine.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: forkMachine (POST /v1/machines/{id}/fork). Guide: Machine lifecycle. Example: Examples.