Source-linked AI summary

Fork, Explore, Commit: OS Primitives for Agentic Exploration

Cong Wang, Yusheng Zheng

arXiv:2602.08199v2cs.OScs.DC

TL;DR

Agentic exploration needs isolated filesystem and process state with atomic commit and rollback across parallel solution paths. The paper introduces branch contexts and Linux implementations, with preliminary BranchFS evaluation showing sub-350 μs creation and under-1 ms commits for small changes.

  • Problem

    Agentic exploration requires isolating filesystem and process state across parallel solution paths while supporting atomic commit and rollback.

  • Method

    The paper introduces branch contexts with copy-on-write isolation, fork/explore/commit lifecycle, first-commit-wins resolution, nesting, BranchFS, and a proposed branch() syscall.

  • Results

    Preliminary evaluation shows sub-350 μs branch creation and under 1 ms commit for small changes.

  • Takeaways & Limitations

    BranchFS and BranchContext provide lightweight, unprivileged primitives and composable patterns for integrating agent exploration with agent frameworks.

  • Takeaways & Limitations

    No existing OS mechanism satisfies all of the stated branch-context requirements.

Abstract

from arXiv · show

AI agents increasingly perform agentic exploration: pursuing multiple solution paths in parallel and committing only the successful one. Because each exploration path may modify files and spawn processes, agents require isolated environments with atomic commit and rollback semantics for both filesystem state and process state. We introduce the branch context, a new OS abstraction that provides: (1) copy-on-write state isolation with independent filesystem views and process groups, (2) a structured lifecycle of fork, explore, and commit/abort, (3) first-commit-wins resolution that automatically invalidates sibling branches, and (4) nestable contexts for hierarchical exploration. We realize branch contexts in Linux through two complementary components. First, BranchFS is a FUSE-based filesystem that gives each branch context an isolated copy-on-write workspace, with O(1) creation, atomic commit to the parent, and automatic sibling invalidation, all without root privileges. BranchFS is open sourced in https://github.com/multikernel/branchfs, along with a Python integration library, BranchContext, that provides ready-to-use agent exploration patterns. Second, branch() is a proposed Linux syscall that spawns processes into branch contexts with reliable termination, kernel-enforced sibling isolation, and first-commit-wins coordination. Preliminary evaluation of BranchFS shows sub-350 us branch creation independent of base filesystem size, and modification-proportional commit overhead (under 1 ms for small changes).

1 Introduction

Agentic exploration requires isolated filesystem and process state while agents pursue parallel solution paths and selectively commit results. The paper introduces branch contexts and two Linux realizations to provide this lifecycle and coordination.

  • 1 Introduction: Existing filesystem and process mechanisms lack the required combination of nested branching, commit semantics, unprivileged operation, and reliable branch-aware isolation.Userspace composition introduces race windows, fragile cleanup, and ordering dependencies.
  • 1 Introduction: Branch contexts provide copy-on-write isolation, fork/explore/commit lifecycle, first-commit-wins resolution, and nesting for agentic exploration.Each context combines an isolated filesystem view with a process group.
  • 1 Introduction: BranchFS provides unprivileged copy-on-write workspaces with O(1) creation, atomic parent commit, and automatic sibling invalidation.It is implemented as a FUSE-based filesystem.
  • 1 Introduction: branch() is a proposed Linux syscall for process spawning with reliable termination, kernel-enforced sibling isolation, and first-commit-wins coordination.
  • 1 Introduction: Preliminary evaluation reports sub-350 μs branch creation and under 1 ms commit for small changes.

2 Motivation

Parallel agent exploration creates requirements for isolated, reversible filesystem and process execution, including atomic single-winner commits and hierarchical branching. Existing mechanisms provide partial capabilities but do not satisfy these requirements together.

  • 2 Motivation: Current frameworks use git stashing, temporary directories, container clones, or per-file snapshots that cannot fully capture shell-command changes or support parallel branching.
  • 2 Motivation: Agentic exploration requires isolated filesystem and process state, atomic single-winner commit, nesting, complete filesystem coverage, lightweight unprivileged operation, and process coordination.
  • 2.3 Limitations of Existing Mechanisms: No existing OS mechanism satisfies the complete set of requirements for agentic exploration.
  • 2.3 Limitations of Existing Mechanisms: UnionFS and OverlayFS lack native commit-to-parent and sibling invalidation, while mounting requires root privileges.
  • 2.3 Limitations of Existing Mechanisms: Btrfs and ZFS support nested clones but are filesystem-specific and lack native commit-to-parent; device-mapper snapshots add O(depth) read latency.
  • 2.3 Limitations of Existing Mechanisms: Process groups can be escaped, cgroups typically require setup and privileges, PID namespaces impose PID 1 overhead, and clone() requires combining mechanisms.Cgroup v2 delegation via systemd can avoid root but requires prior configuration.

3 Branch Contexts

Branch contexts provide isolated, copy-on-write execution environments for parallel agent exploration, with atomic resolution and hierarchical nesting. Their lifecycle is fork, explore, and commit or abort, using first-commit-wins semantics.

  • Branch contexts combine a filesystem view and process group with copy-on-write isolation, atomic commit, single-winner resolution, nesting, and coordinated lifecycle management.
  • They differ from prior speculation systems by exploring multiple paths in parallel, using competitive first-commit-wins resolution, and targeting local agent workloads.
  • Lifecycle: The lifecycle atomically forks N contexts from a frozen origin, runs them independently, then commits one delta to the parent or aborts it without affecting siblings.
  • Core Semantics: The parent becomes read-only while contexts exist, preventing conflicts, while siblings remain isolated and can execute concurrently.
  • Core Semantics: First-commit-wins invalidates all siblings, and nested contexts commit successively to their immediate parents for hierarchical exploration.

4 BranchFS Design and Implementation

BranchFS implements the filesystem dimension of branch contexts through file-level copy-on-write layers, ancestor lookup, and atomic commit or abort. It supports unprivileged standalone or kernel-driven operation.

  • BranchFS gives each branch an isolated copy-on-write workspace with O(1) creation, atomic parent commit, and automatic sibling invalidation without root privileges.
  • File-Level Copy-on-Write: The first modification copies an entire file into the branch delta layer, while unmodified files resolve through ancestor branches to the base directory.
  • File-Level Copy-on-Write: File-level copy-on-write is simpler than block-level copying, with whole-file overhead considered acceptable for small-to-medium agent workload files.
  • Commit and Abort: Commit applies deletions and modified files atomically, increments the parent epoch, and invalidates sibling branches; abort discards the delta without changing the parent.
  • BranchFS can operate without branch(), using CLI or control files, while kernel integration drives branching through generic filesystem ioctls and atomic mount setup.

5 The branch() Syscall

branch() is a proposed Linux syscall that atomically coordinates process, namespace, filesystem, and optional memory branching. Its create, commit, and abort operations enforce isolated first-commit-wins exploration with reliable cleanup.

  • branch() provides reliable process termination, kernel-enforced sibling isolation, memory branching, and PID preservation beyond filesystem-only branching.
  • Interface: The syscall composes cgroups, namespaces, filesystem branches, and signal barriers atomically, avoiding userspace race windows and partial-failure cleanup.
  • Operations and Flags: BR_CREATE creates N child branches with separate mount namespaces, while BR_COMMIT lets one winner apply filesystem and memory changes and terminate siblings.
  • Operations and Flags: BR_ABORT discards filesystem changes and terminates the branch; if every branch aborts, the parent resumes.
  • Nested Branches: Nested branches commit only to their immediate parent, and descendants are terminated on commit or abort for reliable lifecycle cleanup.
  • Generic filesystem ioctls keep branch() filesystem-agnostic, allowing FUSE daemons and kernel-native filesystems to implement the same branching interface.

6 Preliminary Evaluation

The preliminary evaluation measures BranchFS creation, commit/abort, and sequential I/O performance. Branch creation is independent of base size, while commit cost scales with modifications and throughput depends on FUSE mode.

  • Branch Creation: Under 350 μs branch creation remains constant across base directory sizes, confirming O(1) creation cost.The measurement excludes CLI overhead and instruments daemon operation time.
  • Commit and Abort: Under 1 ms commit completes for small modifications, while commit overhead scales with modified data rather than total filesystem size.Abort is similarly fast because it removes only the branch delta layer.
  • I/O Throughput: 7,236 MB/s read throughput in passthrough mode reaches 82% of native, versus 1,655 MB/s in regular FUSE mode.Passthrough bypasses the daemon for unmodified files; regular FUSE pays the kernel-to-userspace roundtrip.

7 Related Work

Related work spans isolation mechanisms and OS-level speculation or transactions. Branch contexts differ by combining nested, long-lived, unprivileged branching with commit semantics in userspace.

  • Isolation Mechanisms: Containers, gVisor, lightweight contexts, Dune, and Capsicum provide isolation through namespaces, sandboxing, protection domains, virtualization, or capabilities.These mechanisms address isolation but are presented separately from branch-context commit and exploration semantics.
  • OS-Level Speculation and Transactions: Branch contexts combine nesting, arbitrary duration, and userspace operation, unlike flat short-lived TxOS transactions requiring deep kernel modifications.Speculator targets distributed filesystem network latency rather than agent exploration.

8 Discussion and Future Work

The discussion identifies unhandled external effects and restricted single-winner resolution, while outlining implementation work and current agent assumptions. It also notes broader rollback uses beyond AI agents.

  • Semantic Extensions: BranchFS does not roll back network, IPC, or device I/O, and currently supports only single-winner semantics rather than merging multiple branches.Future work includes effect gating and file-level, conflict-aware, or semantic merging.
  • Implementation Roadmap: branch() is a design proposal, with BR_FS and BR_ISOLATE planned first and BR_MEMORY deferred because of page-table complexity.The roadmap targets Linux 6.19 for an initial prototype.
  • Implementation Roadmap: File-level copy-on-write has limitations involving absolute symlinks, hardlinks, special files, and disk-space exhaustion.These constraints are described as acceptable for agent workloads but requiring fixes for general use.
  • Current Agent Scope: Current agents primarily checkpoint through files, so BR_FS-only mode is expected to cover most current use cases.BR_MEMORY is intended for agents with substantial in-memory state such as persistent interpreters or embedding caches.
  • Broader Applications: With one branch, the abstraction supports try-and-rollback workflows for package upgrades and system configuration tuning.The same fork/explore/commit abstraction therefore extends beyond AI-agent exploration.

9 Conclusion

The paper presents branch contexts for isolating filesystem and process state during agentic exploration, with BranchFS implemented and branch() proposed. Preliminary results show constant-time creation and modification-proportional commit costs.

  • Conclusion: Branch contexts provide isolated filesystem and process state with atomic commit and rollback semantics for parallel agent paths.The abstraction supports copy-on-write branching, first-commit-wins coordination, and nested exploration.
  • Conclusion: BranchFS supplies unprivileged O(1) creation and atomic commit-to-parent, while BranchContext offers seven composable exploration patterns.branch() is proposed for kernel-enforced process coordination and reliable termination.
Loading 2602.08199v2…