Agent-native version control

Research notes on copy-on-write workspaces for coding agents and AI workflows on self-hosted GitLab

2026-11-02 · 23 min read
contents

Coding agents write code far faster than people can review it. That changes what version control and code review are for. This post collects our research on two ideas and how they fit together: an agent-native copy-on-write workspace layer on top of Git, and AI-assisted development workflows built on a self-hosted GitLab.

It is a research log rather than a finished argument: some parts are designs, some are reading notes, and the open questions are listed at the end.

Summary

The project combines two ideas that meet in the middle. The first is to rebuild AI-assisted development workflows, like GitHub Copilot or GitLab Duo, on a free, self-hosted GitLab: platform-independent, built from open-source parts, with swappable models. The second is our idea for what sits underneath: give every coding agent its own copy-on-write workspace (code, databases, services) so many agents can work in parallel safely. The workflows decide what work an agent should do; the workspace layer gives it a safe place to do that work and hands back proof that it works. The team is Luke, Lucas, Abdellah, and Lars.

The core project is that code is cheap and human attention is the bottleneck. Success means shorter merge-request cycle times and fewer human minutes per merged change, not more AI comments.

The work happens on two levels:

  1. Systems: an agent workspace layer that gives each agent a copy-on-write workspace on top of Git, addressing the disk, resource and review limits of running many agents at once.
  2. Workflows: an event-driven bot on self-hosted GitLab CE for CI triage, merge-request review, fixing review comments, issue triage and issue → MR.

The biggest open gaps are defining the proof packet and the risk score (with mutation testing behind the tests), answering the knowledge-transfer objection to "review the proof instead of the diff", and writing down research questions and metrics.

The problem: agents at scale

With many concurrent agents working on one monorepo, standard tooling breaks along three axes.

  1. Workspaces and disk footprint. Git worktrees isolate source files but not runtime state, ports, databases or build caches. They also duplicate the checkout: 72 worktrees at about 5.4 GB each is roughly 389 GB. One idea is to integrate container-based isolation into worktrees.
  2. Resource contention. Full test suites (for example 12,000 unit tests plus 116 end-to-end suites) exhaust the host. Five concurrent agents easily use more than 16 GiB of RAM, so work starts queuing. This calls for CI runners, multiple runners and test impact selection.
  3. The review bottleneck. In one of my own projects I produced 235 commits and 173,000 lines in 30 days (9 Sep – 15 Oct 2026, N=1). There was a lot of code and a lot of tests, but little of it actually added anything.

Worktrees need runtime isolation

Penligent makes the same point in Git worktrees need runtime isolation for parallel AI agent development. They describe Coasts, which allocates runtime resources dynamically per worktree and lets you choose what is shared between worktrees and what is not.

That raises an obvious question: if every worktree gets its own containerized environment, doesn't that just use more resources? Answering it is exactly the job of a copy-on-write or overlay layer.

Version control compared

Every existing system was designed around an assumption about who is using it. The table below compares those assumptions and where each one breaks once the users are dozens of agents.

System Architecture Assumption Pros Failure mode at agent scale
Git Distributed Human, offline-capable Full local history, rich branching Slow clones, worktrees duplicate GBs, lock contention
SVN Centralized Client-server Central truth, sparse checkouts Fragile merge tracking, global revision locks
Mercurial Distributed Extensible DVCS Clean changeset evolution Same disk/history scaling as Git without virtual FS
Google Piper (+CitC) Centralized monorepo Cloud-first enterprise Virtual workspaces, petabyte scale Proprietary, coupled to Google infra
Meta Sapling + EdenFS Hybrid Huge monorepo FUSE virtual FS, lazy hydration High operational complexity
Anthropic Scion Server-centric Always-online agents & CI Server owns merges/rebases/blame Proprietary, little public detail
Libra Git + Agent Sessions …
Jujutsu
Pijul
Darcs
Agent workspace layer Agent-native CoW on Git Concurrent local/homelab agents Ephemeral CoW branches, fast boot, proofs Under development

Small projects in the same space

A few small open-source projects are attacking parts of the same problem:

SwarmGit and git-stint confirm that per-agent isolation is the first thing people reach for, but both build on plain worktrees. That isolates source files only, so they still run into the disk, port, database and test-resource problems described above. GitAI's prompt-to-code links are closer to our proof packets: both try to attach context to a change so a reviewer doesn't have to rebuild it from the diff.

The agent workspace layer

The agent workspace layer is the systems half of the project. The idea is to treat agents as the primary users of version control: they get cheap, disposable workspaces, and they hand back evidence instead of just a diff.

Patch-first model vs. a materialized filesystem

Agents produce changesets (patches) instead of mutating files directly. That allows commutative reordering of hunks, isolated conflict resolution and fine-grained tracking. Compilers and test runners still need a normal POSIX tree, so the workspace filesystem projects the patches on demand into ephemeral working layers. The pipeline is Git → diffing → change request.

An interesting approach: CRDTs with Loro

Loro is a library for local-first, collaborative apps built on CRDTs (conflict-free replicated data types). Concurrent edits from different peers merge automatically, and every peer converges to the same state once it has seen the same operations. It keeps the full history, so you can travel back to any earlier version, sync incrementally using version vectors, and take shallow snapshots, similar to a shallow Git clone. It has data types for plain and rich text, lists, movable lists, maps and movable trees, and is written in Rust with bindings for JavaScript (via WebAssembly) and Swift.

It is interesting here because it attacks the same problem as a patch-first model from the other side. Instead of reordering patches and resolving conflicts afterwards, a CRDT is designed so that concurrent edits never conflict at the data level. Many agents could edit a shared document, or in principle a source tree, at the same time without locks or merge steps.

The limits matter just as much. A CRDT only guarantees that everyone ends up with the same result, not that the result compiles or passes the tests: two edits that merge cleanly can still break each other's code. Loro has no locking, transactions or write-time permissions, and it is not aimed at source code or at replacing Git. So it is a model for how agents could edit concurrently, but every merged state would still need to go through the workspace layer and produce a proof packet.

Workspace and resource isolation

Each agent gets its own workspace, built from shared layers so that an extra agent costs almost nothing until it actually changes something.

The issue with the patch system is that it's efficient for development but when it comes to building and testing we still need the full source environment.

Proof packets

Instead of reviewing raw diffs, reviewers look at evidence:

  1. The workspace runs the relevant tests and linters.
  2. The workspace layer captures runtime telemetry: assertions, CPU/RAM deltas, test output.
  3. It produces a proof packet: JSON with metadata, the test verdict, the minimal patch and a performance profile.
  4. Routine changes with a full proof can auto-merge; risky ones go to a human with the proof attached.

Still open: which fields and thresholds a proof packet must have, and how a risk score decides what counts as routine and what counts as risky.

Testing research

Coverage is a weak proxy. What matters is whether the tests actually catch faults. This feeds directly into the proof packet: a passing test suite is only proof if the tests are effective.

Mutation testing

From arXiv 2506.02954, an LLM-based mutation loop for unit tests. A mutant is the original code with a small injected fault, created by a mutation operator. A test that fails on a mutant "kills" it, which shows the test is effective. The mutation score (killed mutants divided by total mutants) scores the whole test suite and is more reliable than line or branch coverage.

LLM-based test generation

From arXiv 2605.30914:

However, most existing work evaluates generated test cases primarily based on code coverage metrics, such as line or branch coverage. According to prior studies, high code coverage does not necessarily imply strong fault detection capability. Other research suggests that the mutation score is a more reliable and meaningful metric for evaluating the effectiveness of test cases. […] The mutation score is the ratio of killed mutants to the total number of generated mutants.

This raises two questions for agent-written code:

Spec-driven (contract-first) test generation

From arXiv 2608.17177 (Google). Agents first write down the code's contract, then the tests. On 90 real historical bugs, contract-first caught 63% versus 53% for a normal agent, but only with 5 attempts; with a single attempt the difference was small and not significant. It also cost about 38% more tokens.

The limits are real: both approaches missed many bugs, and the study used one model family, one company's code and an AI judge. Our takeaway is that writing down intent helps a bit but does not solve the problem of low-value AI-written tests.

LLM unit test generation for C

A paper from the UFSCar repository. It is somewhat outdated, opens with mutation-based testing in an LLM loop, and finds that LLMs underperform humans.

Property-based testing

From Testing using property-based tests. Instead of hand-picked examples, the framework generates random inputs within the types and strategies you describe. It is useful for weakly typed languages, and similar to fuzzing but with a different intent:

@given(st.lists(st.integers()))
def test_reverse_twice(xs):
    assert reverse(reverse(xs)) == xs

Properties could feed proof packets as a stronger check than example-based tests.

Getting to less code

A side thread: the goal should be less code, not more. Ideas include a proper type system, fewer layers of abstraction, and explicit invariants. Related reading: AI coding agents add 30% more code, no more output.

What code review is actually for

Bacchelli and Bird studied code review at Microsoft (ICSE 2013). Developers expect review to find defects, but what it mainly delivers is knowledge transfer, team awareness and better solutions. The key activity is understanding the change.

That is the strongest objection to "humans review the proof instead of the diff": it can erode team awareness. Possible answers are risk-based routing, reviewer briefings, and actually measuring awareness.

AI workflows on self-hosted GitLab

The second idea is more practical: rebuild the useful parts of Copilot and Duo for teams that run their own GitLab.

Goals

What Copilot and Duo can do

We are not trying to pick a winner between GitHub Copilot and GitLab Duo. Together they show what an AI-assisted development platform is expected to do today, and that is the feature list for the alternative. The question for each capability is what it would take to build it ourselves without being tied to one model or one vendor.

Capability What it does What a model-independent version needs
IDE completion and chat Inline suggestions and a chat panel in the editor Nothing new: open-source editor plugins already talk to any OpenAI-style API
MR summary and description Summarises a diff and writes the merge-request description Diff from the SCM API, one prompt, any model
AI code review Posts review comments on a merge request Linters, Semgrep and tests first; the model only explains and ranks the output
Applying review feedback Turns a review comment into a suggested change A sandbox to run the change and its tests, then a suggestion block
Issue → MR agent Picks up an issue and opens a merge request with a fix An agent loop in an isolated workspace that returns proof, not just a diff
CI failure analysis Explains why a pipeline failed and suggests a fix Job log, diff and test history; mostly retrieval, so smaller models work
Vulnerability explain / fix Explains a security finding and proposes a patch Semgrep/Gitleaks findings as input, fixes re-scanned before they are proposed
Issue triage Suggests labels, owners and duplicates CODEOWNERS, history and embeddings; any embedding model will do

The table still needs to be checked against the current Copilot and Duo documentation, since both products change quickly.

Where they fall short

The alternative fixes these by design: every model call goes through an OpenAI-compatible gateway (so any hosted or self-hosted model fits), the SCM sits behind an adapter, and prompts and rules live in the repo.

IDE assistants are already a commodity. The value is in the server-side, event-driven parts: merge requests, issues and CI.

Use cases, ranked by value per effort

  1. CI failure triage. Probably the biggest win. Read the failed job log, the diff and the test history, then post the probable cause, whether it looks flaky or real, and the files involved. Read-only and low risk.
  2. MR description and reviewer briefing. What changed, where the risk is, and what to look at first. Cheap, and it builds trust.
  3. Automatic MR review. Deterministic tools first (linters, Semgrep, Gitleaks, type checker, tests), with the LLM explaining and ranking their output. A strict noise budget: at most N comments, each with a confidence and a failure scenario, no style nits. Inline discussions via the GitLab Discussions API; thumbs-up/down reactions and resolved/dismissed threads give a precision metric.
  4. Fixing review comments. @bot fix starts a sandbox (CI job or container) that produces a change plus tests. Start with GitLab suggestion blocks only, so a human clicks apply; move to pushed commits later.
  5. Issue triage. Suggest labels, priority, component and team (from CODEOWNERS and history), and detect duplicates with embeddings. Suggest-only until the accuracy is proven; evaluate by replaying closed issues.
  6. Issue → MR. Only for issues labelled ai-fixable: an agent works in a sandbox and opens a draft MR with tests and an evidence pack, which then goes through normal review. This is where the agent-native ideas apply directly.

Other speed-ups: risk-based review routing, test impact selection, nudges on stale MRs, release notes from merged MRs, and Renovate MRs with summarized breaking changes.

An earlier version of the workspace-layer design pushed commits directly in response to review comments and applied labels directly. The safer order above should win: suggestions first, suggest-only triage, and write access only from a trusted trigger.

Decision models for automatic triage

Letting a language model decide on its own where an issue goes, or whether a merge request needs a human, is hard to audit and changes every time the model changes. A decision model splits the job in two: the model (or plain code) extracts features, and an explicit, versioned set of rules makes the call.

This keeps triage model-independent. Swapping the LLM only changes how features are extracted; the routing logic, its thresholds and its audit trail stay the same. It is also the most concrete way to define the risk score that decides which proof packets can merge without a human.

Architecture

The bot is event-driven: GitLab webhooks go into a queue, workers pick up events, call tools and models, and write results back through an adapter.

GitLab (self-hosted)                              Model gateway
  webhooks ──► [ adapter: gitlab ] ─┐            ┌─ LiteLLM / OpenAI-compatible API
  API      ◄── [ adapter: gitea  ] ─┤            │    ├─ vLLM / Ollama (self-hosted)
                                    ▼            │    └─ external API (opt-in, per repo)
                          [ event queue ] ──► [ workers ] ──► [ tools: lint, semgrep, tests ]
                                                  │
                                                  ├─► [ sandbox runner: GitLab CI job / container ]
                                                  ├─► [ audit log + metrics (Postgres) ]
                                                  └─► [ policy: who/what/where may the bot act ]

Build vs. reuse

The realistic outcome is "PR-Agent plus a custom CI-triage and fix worker", not a full platform.

Security and governance

A bot that reads untrusted text and can write to repositories needs hard limits.

Evaluation

Plan

  1. Research and baseline (weeks 1–3). Check the Copilot and Duo capability table against the current docs, run 5–8 developer interviews, collect baseline metrics from the GitLab API, and check the hardware (GPU/CPU) available for self-hosted models.
  2. Choose (week 4). Rank the use cases by effort, risk and gain, and pick two or three.
  3. Skeleton plus a cheap win (weeks 5–7). Webhook receiver, queue, GitLab adapter, model gateway and audit log, with MR descriptions and CI triage in one pilot repo.
  4. Core use cases (weeks 8–12). MR review with a feedback loop, fixing review comments (suggestions first, then sandbox jobs), and suggest-only issue triage.
  5. Evaluate and report (weeks 13–16). Offline replay plus pilot vs. baseline, ending in a keep / drop / next recommendation.

Questions before a pilot

How the two ideas fit together

The workflow bot is the front end and the workspace layer is the engine underneath. The bot reacts to events (a failed pipeline, a review comment, an ai-fixable issue) and decides what an agent should do. The workspace layer gives that agent a cheap, isolated copy of the repo, its services and its database, runs the tests, and returns a proof packet that the bot posts back on the merge request.

The two should still stay separable. The bot has to work with plain CI jobs as sandboxes, so it shows on its own that open-source tooling and replaceable models can replicate Copilot and Duo on self-hosted GitLab without lock-in or new infrastructure. The workspace layer (OverlayFS, copy-on-write branching, test scheduling and proof packets) must not depend on GitLab, so it can be evaluated on its own. That way the practical half never depends on a research prototype.

Open questions

These are the gaps we still need to close.

Proof is central but undefined

The knowledge-transfer objection

If review mainly delivers knowledge transfer, replacing diffs with proofs needs an answer for how teams stay aware of their own codebase.

Research questions and evaluation

Deployment context

Further reading

Papers

Articles and docs

Version control

Jujutsu, Pijul, Darcs, Sapling / EdenFS, Loro

Tools

PR-Agent, OpenHands, Aider, SWE-agent, Semgrep, Gitleaks, Renovate, LiteLLM, vLLM, Ollama, Bubblewrap, sccache, Neon, Dagger, Firecracker


← back to blog