SmolForgeField Notes

Notes on systems,
code, and craft.

SmolForge journal

Field notes

All notes23
Engineering

7 Performance Traps in AI-Coded Apps

10 min
Engineering

Auditing an AI-Built GitHub Clone

9 min
Engineering

Forge CI Got 4x Faster

12 min
Product architecture

Git Worktrees Aren’t Agent Environments

9 min
Product architecture

Forge’s Plan for Observable Skill Kits

52 min
Product architecture

We’re Building a Program Database

24 min
Engineering

We Stopped Letting Feature Agents Deploy

12 min
Engineering

We Deleted Two Skills That Tried to Help

14 min
Engineering

Forge Git Is Fast. Cold Checkout Isn’t.

5 min
Architecture

High-Throughput Agents Need a Routed Monorepo

14 min
Engineering

A 14-Second Checkout Still Produced a 16-Minute Build

9 min
Engineering

Durable Git Staging Still Failed During Releases

8 min
Engineering

We Let Forge’s Tests Reach 62,000 Lines

8 min
Architecture

We Split Forge’s API Into Five Workers

8 min
Engineering

Forge Escaped Its Self-Deploy Loop

9 min
Engineering

523 Routes Moved Without a Rewrite

9 min
Product architecture

Forge Sites Now Composes Build, Identity, and AI

6 min
Engineering

We Compared Flue, Mastra, and AI SDK Harness

7 min
Product architecture

Forge Agents Now Speak MCP

7 min
Product architecture

Every Repository Got Its Own Coding Agent

8 min
Engineering

Projected Checkpoints Cut Checkout 96%

8 min
Engineering

Exact-SHA Archives Cut Checkout 89%

7 min
Engineering

130 MiB Pushes Stay Ordinary

7 min
All notes

Product architecture

Git Worktrees Aren’t Agent Environments

Two agents shared one exact base without sharing dirty files.

Codex and Claude worked from one pinned repository state without seeing each other’s changes; a backend bake-off made full-copy the correctness-first baseline.

Codex and Claude Code received the same repository snapshot and the same assignment. Each had to edit shared.txt, delete one file, rename another, create a relative symlink, make a script executable, and leave a nested result. Codex finished first, so its workspace was already dirty when Claude inspected its own copy.

Claude saw none of Codex's changes. Codex saw none of Claude's. The source tree remained unchanged.

The test sounds like a job for Git worktrees. It was not. A worktree is a version-control working tree; an agent environment is a private writable view pinned to one exact base. Those ideas overlap, but making them the same object gives Git responsibility for a lifecycle that coding agents need even when no branch, commit, or repository exists.

Our first working backend was deliberately boring: a full directory copy. APFS copy-on-write cloning looks like the likely macOS optimization, while AgentFS 0.6.4 failed its first mutation on the tested host. The important result is not that copies beat worktrees. It is that workspace isolation can stand on its own, leaving Git to handle history and publication.

Screenshot of an August 10, 2026 post by swyx saying worktrees must die because the displayed worktree folders contained 20 GB of repeated node_modules data.
The motivating complaint was literal. The first directory search found 20 GB of repeated node_modules; widening it to all coding work from the preceding week raised the observed total to 50 GB. The screenshot records the original August 10 post on X. These local totals motivate the experiment but are not a generalized storage benchmark.

Worktrees solve version control

Git worktrees are useful. Git's own documentation describes them as multiple working trees attached to one repository. A linked worktree shares repository data while keeping per-worktree state such as HEAD and the index. If the task begins with “check out another branch,” that is exactly the right model.

Agent concurrency begins one step earlier. The input may be a Git commit, but it may also be a content-addressed snapshot, generated fixture, database state, or checkpoint from another agent. The agent needs a directory in which normal tools work. It does not necessarily need a branch.

Coupling the two makes workspace creation inherit Git's refs, indexes, locks, cleanup rules, and administrative directories. None of those are defects. They are evidence that Git is solving a larger problem.

The separation we wanted was smaller:

workspace     which files this attempt can see and change
checkpoint    the exact result this attempt produced
publication   who may advance the canonical state

Writing a directory should not grant publication authority. Creating a private directory should not require creating a branch.

The environment is an ordinary directory

The prototype scans a source tree, excluding administrative roots such as .git, and records an exact content manifest. It materializes that manifest as an immutable base, verifies that the source did not change during preparation, then gives every agent a separate writable directory:

                 immutable base a8cd…807ff
                         /       \
                        /         \
                materialize   materialize
                    /               \
             Codex directory   Claude directory
               dirty files       different dirty files

This is the minimum model: one pinned base, two native directories, no shared dirty state.

“Native directory” is doing substantial work here. Editors, package managers, TypeScript language servers, test watchers, build tools, local databases, and ordinary shell commands already understand filesystem paths. A custom file API would require every tool to cooperate with the abstraction. A normal directory lets the abstraction disappear below them.

The prototype targets trusted coding agents. It prevents accidental collisions between managed workspaces; it is not a hostile-code sandbox. A same-user process can still open another absolute path or inspect host credentials. Containers and virtual machines can add that security boundary later without redefining the workspace contract.

The backend bake-off favored a boring oracle

Once the environment contract was independent from Git, we could compare materialization backends without changing what an agent sees. Full-copy became the correctness oracle: every faster backend must produce the same visible tree and the same checkpoint.

Backend What the experiment observed Decision
full-copy Native watchers and tools worked; startup and disk scale with source size Prototype default and correctness oracle
apfs-clone Matched canonical results on two arm64 APFS hosts and sharply reduced initial physical growth Keep experimental until repeated performance gates pass
AgentFS 0.6.4 First mutation timed out after about 30 seconds on the tested Apple-silicon host Reject this version/profile; keep only a bounded external adapter

The copy baseline needed one correction before it could be trusted. Rust's ordinary file copy transparently produced APFS clones, making a supposed one-gigabyte byte copy complete below the timer's millisecond resolution. The harness now uses an explicit userspace read/write loop. That invalidated the earlier performance numbers without changing semantic results.

With the corrected oracle, a single one-gigabyte-file run prepared the full copy in 357 milliseconds and allocated about 1.07 GB. The forced APFS clone completed below one millisecond of report resolution with effectively no initial allocation. On a 100,000-file fixture, full-copy preparation took 28.9 seconds and about 2.13 GB; APFS cloning took 13.2 seconds and about 50 MB.

That is enough to keep APFS compelling, not enough to make it the default. The 100,000-file clone missed the provisional five-second startup gate, and these were individual ordered runs rather than randomized distributions. The scan after mutation was also slower in that APFS sample. A good optimization must report that cloning really occurred, preserve semantics, and win repeated workloads. Silent fallback would make both capability and performance claims untrustworthy.

AgentFS offered a more ambitious alternative: persistent copy-on-write state in SQLite with a mounted or sandboxed filesystem interface. We tested its official Apple-silicon 0.6.4 release as an external process rather than embedding its SDK or adopting its database as canonical state. Initialization succeeded, but the first command exited after 30.045 seconds with connection pool timeout: no connections available. No mutation occurred and no process or mount leaked. The exact reproduction remains in AgentFS issue #342.

That rejects one release on one host. It does not condemn AgentFS. More importantly, the failure did not force a redesign: a future version can re-enter the same oracle through the same bounded adapter.

Node tooling tested the abstraction leaks

File creation alone would have been a weak proof. JavaScript tooling stresses the parts of filesystem abstractions that tend to leak: large private dependency graphs, atomic replacements, recursive watching, generated output, long-running servers, and many small files.

The full-copy service completed 30 fresh npm environments and 30 fresh pnpm environments on an arm64 Mac. Every run kept node_modules inside its private directory, left the base unchanged, and cleaned up successfully. The fixture exercised TypeScript compilation and tsserver, changed responses from Vite and Next.js, and observed a second passing watcher run from Jest and Vitest.

The median npm install was 3.7 seconds and its median complete workload was 9.2 seconds. Pnpm's medians were 3.5 and 10.5 seconds. These are fixture-and-host measurements, not general package-manager benchmarks. Their value is compatibility evidence: the ordinary-directory contract survived tools that would quickly expose a leaky virtual filesystem.

Two earlier npm attempts stalled while waiting for Jest's first watcher event. A diagnostic run and all 30 isolated repetitions passed, so the result remains an unreproduced concurrency-sensitive harness flake—not a filesystem failure and not evidence to discard.

Real agents failed above the filesystem first

The first Codex and Claude launch did not pass. Codex CLI 0.142.5 was configured with a model that required a newer client. Claude Code 2.1.201 needed its local login refreshed. Both stopped before mutating their directories.

After selecting a locally supported Codex model and refreshing Claude's credential, both agents completed the file-operation contract. Claude inspected its environment after Codex's was dirty and still saw only the pinned base. The adapter failures were useful because they exposed another naming problem: an “agent environment” crosses several independent layers.

  • Workspace isolation separates source and dirty files.
  • Dependency isolation keeps mutable install graphs private while immutable caches may be shared.
  • Runtime isolation scopes processes, ports, sockets, temporary paths, and databases.
  • Checkpointing extracts an exact immutable result.
  • Publication authority decides whether that result becomes canonical.

Calling all of these “the sandbox” makes failures harder to diagnose and encourages one mechanism to claim authority it does not need.

This replaces one use of Git, not Git

For trusted coding agents, this model can replace worktrees as the local concurrency mechanism. A small command surface is enough:

pdb-env create alpha
pdb-env run alpha -- codex
pdb-env create beta
pdb-env run beta -- claude
pdb-env path alpha
pdb-env discard alpha

The research prototype is not yet an installable product. It also does not replace commit history, merging, signed provenance, remotes, review, reflogs, or Git's recovery ecosystem. A practical workflow can use agent environments for working state and Git for publication.

The next implementation slice is therefore modest: package the full-copy environment switcher, retain the exact base manifest, and rerun the core file-operation proof outside the original PDB repository. APFS can become an optimization after forced-clone observability and repeated benchmarks justify it. Checkpoint publication remains a separate decision.

An agent's writable directory should not acquire publication authority merely because Git created it. Once the writable attempt becomes its own product boundary, the first useful implementation gets smaller: one exact base, one ordinary directory per agent, and one honest oracle for every faster backend.

The complete research repository includes the backend design, exact receipts, proposed decision record, and real Codex/Claude proof. This post was reconstructed from those artifacts with AI assistance; all performance claims are bounded to the recorded August 10, 2026 fixtures and hosts.