RevGuard: Transactional, Version-Bound Contracts for LLM Document Editing

Jinkun Chen, Xuemin Yu, Sijia Han, Vlado KeseljarXiv 2026

TL;DR

When you ask an LLM agent to edit a shared document, "be careful" isn't a systems guarantee—especially if a human collaborator is editing the same file simultaneously. RevGuard solves this by treating AI edits like database transactions, translating vague natural-language instructions into strict, version-bound rules before a single byte is committed. It stops accidental overwrites and collateral damage cold, showing how deterministic guardrails can safely tame probabilistic editors.

What Problem Does This Paper Address?

Imagine asking an AI agent to update your paper's title. While the agent is thinking, your co-author rewrites Section 2. The agent then finishes its thought and overwrites the entire file with the older version it read five seconds ago. The document still compiles, the title is updated, and your co-author's work has silently vanished.

This is a classic systems hazard (specifically, a time-of-check-to-time-of-use bug) colliding with probabilistic AI. Natural-language instructions tell an agent what to achieve, not what write authority it has when a workspace is changing underneath it. Furthermore, relying on the same LLM to propose an edit, interpret its own boundaries, and judge whether the result is safe leaves shared repositories vulnerable to silent deletions, scope creep, and lost updates.

Methods

Instead of trusting raw text patches, the authors borrow classic systems principles—database transactions, optimistic concurrency control, and least privilege—and adapt them for LLM mutations.

At the core of RevGuard is an immutable edit contract bound to a specific base version of the workspace. A contract explicitly defines:

  • Allowed files and read/write sets.
  • A maximum changed-line budget.
  • Exact text fragments ("preservation atoms," like \author{...} or citation labels) that must survive the edit.

The clever twist is how you get a machine-readable contract from a messy human prompt without making it too broad (unsafe) or too narrow (causing unproductive refusals):

Figure 1: REVGUARD separates probabilistic proposal from deterministic enforcement. An LLM compiler and an independently prompted LLM verifier propose a contract for instruction I; a deterministic projection grounds and installs the final contract Cf. The editor stages a minimal edit against the versioned workspace, and deterministic preview and commit enforce the write scope, change budget, and preservation atoms under concurrent events.
  1. Probabilistic Setup: One LLM (the compiler) reads the prompt and workspace to draft a contract. A second, independently prompted LLM (the verifier) reviews and refines it.
  2. Deterministic Projection: Trusted, non-AI code normalizes the contract, strips redundant rules, checks that preserved strings actually exist in the base files ("grounding"), and locks the contract in place.
  3. Transactional Execution: The editor LLM stages its changes and runs a deterministic preview, generating a unique transaction ID tied to the exact workspace state. At commit time, if a concurrent edit has caused version drift, or if any contract rule is violated, the commit is deterministically refused.

Datasets

No models are trained; instead, the authors introduce a reproducible evaluation benchmark built on licensed, compilable multi-file $\text{\LaTeX}$ repositories:

  • Primary Splits: An Oxford thesis template (development), Gemini poster template (validation), and LIPIcs + NSFC application templates (frozen test).
  • Stress & Repair Pools: Three fresh licensed repositories (30 tasks) for cross-model stress testing, plus 16 exact-preservation tasks from distinct repositories for a targeted repair study.

Unlike broader software benchmarks like SWE-bench, this benchmark injects controlled concurrency and staging faults across six task families (e.g., write scope, macro preservation, cross-file dependencies) and evaluates setup reliability, commit safety, and task completion separately.

Key Insights and Ideas

  • Git merge $\neq$ semantic safety: You might wonder, "Why not just use git merge?" In a post-review test, Git's three-way merge cleanly reconciled all concurrent text changes without conflicts, yet happily committed 123 out of 180 unauthorized or destructive semantic faults (like blowing past line budgets or deleting protected macros). Git understands line compatibility; contracts understand permission.
  • Compilation is a validity check, not an authorization check: A $\text{\LaTeX}$ project can compile cleanly even if an agent accidentally writes \\cite instead of \cite or deletes a paragraph. Deterministic preservation invariants catch what compilers miss.
  • Tighter isn't always better: Surprisingly, human-authored "reference" contracts had slightly lower task success than LLM-compiled ones. If a contract is maximally tight, minor friction causes the system to safely refuse the edit—proving that compiling permissive yet safe contracts is a delicate balancing act.

Key Results

  • Primary Frozen Test (144 episodes): Using Claude Haiku 4.5 and GPT-5 mini, zero injected faults were committed and every episode terminated cleanly. Both compiler-only and verified contracts succeeded on 46/48 (95.83%) tasks, slightly edging out human-written reference contracts (44/48). Independent LLM verification improved contract authorization in 7/48 paired cases without losing safety protections, though equal 46/48 task scores meant it didn't show an end-to-end task-utility boost.
  • 900-Cell Cross-Model Stress Test: Adding Gemini 2.5 Flash and unmanaged baselines revealed a stark divide:
Figure 3: Task success versus committed controlled faults for the five protocol packages in the descriptive 900-cell stress test. Each package crosses 30 tasks, three editor models, and two repeats; the whole-file replace package has 179 resolved cells because one cell remained an unresolved provider outcome.

Managed contract protocols committed 0 faults with high success (89.44% compiler-only; 83.89% verified). Conversely, unguarded and content-bound patching baselines committed 132 and 120 faults, respectively, while safe whole-file replacement succeeded just 4.47% (8/179) of the time.

  • Grounding Repair: In the stress test, one verified contract setup failed closed due to an over-escaped string, leaving the strict all-cell preregistered claim formally inconclusive. A versioned deterministic fix (VERIFIED-G) subsequently achieved 48/48 valid setups with zero faults on 96 paired episodes.

Limitations and Future Work

The authors are admirably transparent about their boundaries. First, "zero faults" means zero tested benchmark faults on localized $\text{\LaTeX}$ edits—exact string checks and compilation cannot guarantee good prose, factual accuracy, or human satisfaction. Second, the primary test relies on a small sample of 12 task clusters across two repositories, leaving statistical confidence intervals too wide to prove strict task-success non-inferiority between verified and unverified contracts. Finally, contracts still rely on API-served LLMs whose behavior can drift over time. Future work aims to test longer-horizon editing workflows, add human/semantic evaluations alongside deterministic guards, and refine how permissive contracts are compiled from ambiguous prompts.

Summary updated

BibTeX
@misc{chen2026revguard,
  author = {Jinkun Chen and Xuemin Yu and Sijia Han and Vlado Keselj},
  title = {{RevGuard: Transactional, Version-Bound Contracts for LLM Document Editing}},
  year = {2026},
  eprint = {2611.40161},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.40161},
}
Figure