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 readcontents
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:
- 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.
- 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.
- 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.
- 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.
- 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 (Python,
alpha) runs several coding agents in parallel, each in its own
git worktreeon a dedicated branch. An LLM can split a task into subtasks, and finished branches are merged back intomainone at a time, with conflict handling. - git-stint (Node.js)
gives every agent session its own branch and worktree under
.stint/. Claude Code hooks track changes, start a session automatically when an agent writes tomain, and checkpoint unfinished work;squash,prandendhandle cleanup. - GitAI (Go) comes at it from another angle: it version-controls the prompts next to the code, tracking token counts, cost, intent and which code came from which prompt.
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.
- OverlayFS / copy-on-write:
lowerdiris the read-only clean repo plus the base build cache atHEAD;upperdiris a per-agent tmpfs or CoW layer that is discarded when the work completes or is rejected. The target is a workspace boot under 100 ms with zero initial disk overhead (a target, not a measurement). - Build artifacts via content-addressed storage: shared caches such as sccache, Turbo or the Bazel/Buck2 CAS. The target is a ~99% hit rate for unchanged units (again a target, not a measurement).
- Process and service namespacing: Bubblewrap or rootless Podman
instead of VMs. Network namespaces give each agent its own loopback, so
several agents can all bind
localhost:5432or:8080. - Database branching: ephemeral schemas, or
CREATE DATABASE agent_tmp TEMPLATE base_db;
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:
- The workspace runs the relevant tests and linters.
- The workspace layer captures runtime telemetry: assertions, CPU/RAM deltas, test output.
- It produces a proof packet: JSON with metadata, the test verdict, the minimal patch and a performance profile.
- 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:
- Can we generate effective tests by mutating the original code, and treat tests that fail on the mutant as effective?
- Test tampering: if the agent changes the source while writing the tests, and the tests then pass, did they really pass? Options are locking pre-existing tests, generating tests separately from the code, or gating on mutation score.
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
- Map what GitHub Copilot and GitLab Duo can do across the development lifecycle and pick the high-value capabilities.
- Rebuild them on free, self-hosted GitLab, without paid Duo or Copilot features.
- Stay model-independent: any hosted or self-hosted model can be plugged in, per task.
- Stay SCM-independent where practical and use open-source parts.
- Prove it in small steps: choose → proof of concept → integrate → evaluate. "Not another chatbot."
- Match the useful parts of GitHub Advanced Security (GHAS) where possible.
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
- Model choice belongs to the vendor. You get the models the product supports, on the vendor's terms. Running your own model is either impossible or limited to higher paid tiers.
- Tied to one platform. Copilot's server-side features assume GitHub and Duo's assume GitLab. Neither helps a team that wants to keep its options open.
- Paid and often cloud-hosted. The useful parts sit behind paid tiers, and code, issues and job logs leave the building unless you pay for a self-hosted setup.
- A black box. Prompts, rules and thresholds are not in your repository, so you cannot review, version or tune how the bot behaves.
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
- 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.
- MR description and reviewer briefing. What changed, where the risk is, and what to look at first. Cheap, and it builds trust.
- 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.
- Fixing review comments.
@bot fixstarts a sandbox (CI job or container) that produces a change plus tests. Start with GitLabsuggestionblocks only, so a human clicks apply; move to pushed commits later. - 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.
- 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.
- Inputs: facts about the change or issue. For a merge request: files touched, size, churn, ownership, whether it touches sensitive paths (auth, migrations, public API), test and mutation results from the proof packet. For an issue: component, severity, reporter, similar past issues, and a classification of the text by the LLM.
- Decision: a decision table or a small scoring model maps those inputs to an outcome. For merge requests: auto-merge, quick review, full review or block. For issues: labels, priority, owning team, or "needs a human".
- Form: start with hand-written decision tables (for example in the DMN standard), so the rules are readable and reviewable in the repo. Once there is enough history, replace or calibrate them with a trained model such as just-in-time defect prediction (Kamei et al. 2013).
- Output: every decision records which rule fired and why, so a reviewer can see the reason and the rules can be tuned when they get it wrong.
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 ]
- SCM adapter interface:
get_diff,post_inline_comment,post_suggestion,get_job_log,open_mr,set_labels. The core never calls GitLab directly. - Swappable models via an OpenAI-compatible gateway, with the model chosen per task in config.
- Agents run in GitLab CI with scoped tokens, reusing the existing runners, caches, secrets and logs.
- Prompts and rules live in the repo (for example
.ai/review.md), so they are versioned and reviewed like code. - In the workspace-layer variant, an orchestration daemon (FastAPI or Go) dispatches work into copy-on-write sandboxes, which return proof packets to GitLab.
Build vs. reuse
- PR-Agent (Qodo, open source) does MR review, descriptions and suggestions and supports GitLab: the baseline for use cases 2–3.
- OpenHands, Aider and SWE-agent are open-source coding agents for use cases 4 and 6.
- Claude Code or the Agent SDK in headless mode has a strong agent loop but is an external provider; it should be compared against self-hosted options.
- Semgrep, Gitleaks and Renovate form the deterministic base layer.
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.
- Prompt injection: issue and MR text is untrusted. Bots that read it may only comment; write access comes only from a trusted trigger, such as a maintainer's comment.
- Least privilege: one bot user per capability, project-scoped tokens, no merge rights.
- Data residency: self-hosted models by default; external APIs are opt-in per repo.
- Secret and PII redaction: strip API keys, passwords, database URIs and internal IPs from diffs, issues and job logs before they reach a model.
- SAST validation loop: run SonarQube, Semgrep or ESLint on AI fixes in an isolated runner, and reject fixes that introduce critical vulnerabilities.
- License and dependency audit: inspect new dependencies (package.json, pom.xml, requirements.txt) for incompatible licenses and known CVEs.
- Audit: log every prompt, model, output and action, and make every action reversible.
Evaluation
- Offline: replay around 100 merged MRs (does the bot find bugs that were fixed later, using SZZ as ground truth?), replay closed issues for triage accuracy, and replay failed pipelines for CI-triage accuracy.
- Online: time to first review, MR cycle time, bot comment precision, suggestions applied vs. proposed, triage labels kept vs. changed, and cost and latency per event.
- Baseline: two to four weeks of the same metrics before the pilot starts.
Plan
- 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.
- Choose (week 4). Rank the use cases by effort, risk and gain, and pick two or three.
- 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.
- 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.
- Evaluate and report (weeks 13–16). Offline replay plus pilot vs. baseline, ending in a keep / drop / next recommendation.
Questions before a pilot
- Which repos and languages for the pilot (ideally one active repo with good tests)?
- Is there GPU capacity for self-hosted models, or is an external API acceptable for some repos?
- Is a second SCM (Gitea, GitHub) realistic, or is "SCM-agnostic" a hedge?
- Who maintains the bot in the long run?
- Are developers comfortable with bot comments on their MRs during 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
- What exactly must a proof packet contain (fields, thresholds)?
- How does mutation testing tie into it?
- How do we handle agent-written tests and test tampering?
- What risk score routes a change to auto-merge or to a human? Just-in-time defect prediction (Kamei et al. 2013) suggests features like files touched, size, ownership, churn and sensitive paths (auth, migrations, public API).
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
- Write down the research questions and hypotheses.
- Define the metrics and baseline: workspace startup time, disk and RAM per extra agent, test wait time, and review time per change.
- Design the evaluation setup. N=1 is not enough: either add a second codebase or treat it as a threat to validity.
Related work
- Version control: Jujutsu, Pijul, Darcs; Google's Piper/CitC and Meta's EdenFS.
- Workspace isolation: btrfs/ZFS snapshots, Nix/devenv, Docker overlay, Neon/Postgres branching, Firecracker snapshots, Dagger, Bazel/Buck2 remote execution, Coasts.
- A clear novelty argument against "container-use + overlayfs + a Postgres template database".
Deployment context
- Languages, repo sizes, CI runner capacity and GPU availability of the target setup.
- Which open models are good enough on the available hardware.
- Privacy and the works council: consent, GDPR, and Goodhart effects of measuring developers.
Further reading
Papers
- Bacchelli & Bird 2013, Expectations, outcomes, and challenges of modern code review: doi:10.1109/ICSE.2013.6606617
- Kamei et al. 2013, just-in-time defect prediction: doi:10.1109/TSE.2012.70
- Potvin & Levenberg 2016, Google's monorepo and Piper: doi:10.1145/2854146
- Śliwerski, Zimmermann & Zeller 2005, SZZ: doi:10.1145/1083142.1083147
- Microsoft CodeReviewer (2022): arXiv 2203.09095
- DeepTriage, bug assignment: arXiv 1801.01275
- Ekstazi, regression test selection: doi:10.1145/2771783.2771784
- ACM 10.1145/3764068 (on testing)
Articles and docs
- GitHub Octoverse 2026: commits and pushes reach new highs as developers build with agents
- GitLab REST API (discussions, suggestions, job traces, webhooks, labels)
- Microsoft SDL: GitHub Advanced Security
- SWE-bench and its weaknesses
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