Skip to main content
When one task has multiple candidate strategies, preserve the main path and branch only the temporary exploratory state. Current MuBit supports this with two complementary tools:
  • checkpoint() on the control plane for the durable main-path snapshot
  • core session create / commit / drop for reversible what-if branches

Decision model

RequirementPrimitive
Preserve the current durable task state before compaction or divergencecheckpoint()
Try a temporary branch and discard it latercore.create_session, core.commit_session, core.drop_session
Reload a saved scratch pathcore.snapshot_session, core.load_session

Minimal implementation example

branch_what_if.py
from mubit import Client
import os

run_id = "claims:planner:claim-42"
client = Client(
    endpoint=os.getenv("MUBIT_ENDPOINT", "https://api.mubit.ai"),
    api_key=os.environ["MUBIT_API_KEY"],
    run_id=run_id,
    transport="http",
)

client.checkpoint(
    session_id=run_id,
    label="before-strategy-branch",
    context_snapshot="Planner has two settlement strategies to compare.",
    metadata={"stage": "what-if"},
)

base = client.core.create_session({})
branch = client.core.create_session({"parent_session_id": base["session_id"]})
branch_id = branch["session_id"]

snapshot = client.core.snapshot_session({"id": branch_id, "session_id": branch_id})
client.core.load_session({"session_id": branch_id, "snapshot": snapshot.get("snapshot")})
client.core.drop_session({"id": branch_id, "session_id": branch_id})

Failure modes and troubleshooting

SymptomRoot causeFix
Main path gets overwritten by experimentationNo durable checkpoint before branchingAlways checkpoint the primary path first
Scratch changes vanish too earlyBranch was dropped before reviewSnapshot or commit only after inspection
Compaction loses the decision contextBranching happened without checkpointingSave a checkpoint before diverging

Next steps