Two Agents, One Record: Git-Style Branches Instead of Row Locks
Two agents doing read-modify-write on shared memory lose updates silently: because an agent writes back the whole record it read, a stale save can reset a field another agent just changed, and both report success. The post walks through the three usual fixes—single writer, row locks or optimistic version checks, last-write-wins—and argues all fall short for multi-step tasks spanning several records, since none produces a reviewable diff or an audit trail. It then demos Omnigraph, an MIT-licensed graph database in Rust with a Git-style model: each agent commits to its own branch, merges compare against the merge base, and a stale branch is rejected with divergent_update instead of publishing. The walkthrough uses Claude Code and Codex, covering @key stable IDs, --snapshot reads of old commits, and a Cedar policy with per-agent tokens returning HTTP 403 for writes to main. Useful for anyone building multi-agent shared state, though the headline's 1,000-agent scale is never shown—the demo is one developer and two agents.