Agentic AI
New safety contract ensures AI code editors work with consistent repository state
Researchers propose a method to prevent code-editing agents from mixing data from different versions when querying live repositories.
When software agents edit code repositories while simultaneously querying them, they face a subtle but dangerous problem: information from different repository versions can get mixed together in a single response. A new research paper addresses this vulnerability by establishing a complete-revision publication contract that ensures every query result represents a consistent snapshot of the codebase at one moment in time.
The Problem: Mixed-Revision Context#
Editing agents typically pull data from multiple sources — raw source code, symbol tables, dependency graphs, and retrieval indices — which often refresh at different times. This asynchronous nature creates an opportunity for inconsistency. During an update cycle, a successful query might combine facts that never coexisted in the same repository state, a condition the authors term mixed-revision code context. Such inconsistencies could lead to unsafe code transformations or incorrect refactoring operations.
The Solution#
The researchers propose that before any query-visible publication point, a service must either wait for consistency, report unavailability, or return a complete older revision. After that boundary, it serves only a complete new revision. This guarantees a shared version identity and publication boundary across every piece of information returned in one response — giving the agent a meaningful, testable understanding of what repository state it's working with.
Real-World Implementation#
The team instantiated this approach in a tool called Codetrip, which combines source, symbol, and graph facts in a single operation. Testing on frozen versions of the Gin and Cobra codebases showed dramatic improvements: in controlled trials with five different edit scenarios, traditional live-source composition produced two unsafe responses in 150 trials, while complete-revision publication produced zero unsafe responses under identical conditions.
The authors also implemented journaled, idempotent publication with five durable recovery boundaries, achieving median restart-to-context latency of 77–131 milliseconds across 300 recovery trials. In a separate rename operation probe, mixed-revision context never occurred in 30 Codetrip trials, whereas it occurred in every trial of two competing systems (CodeGraph and codebase-memory-mcp) before they eventually converged.

