Connecting Paperclip, Hermes, and Your Local Agent Harness Using Obsidian and Git
Running autonomous coding agents in isolated containers keeps your host operating system clean, but sharing repositories across a multi-agent control plane and an autonomous execution agent introduces immediate concurrency hazards. When multiple containerized workers pull, edit, and commit against the same Git repository or Obsidian vault simultaneously, uncoordinated index operations collide. Worse, an automated assistant attempting to clean temporary build artifacts can run an unvetted reset that wipes out uncommitted unit tests and source code before opening a pull request.
In this guide, you will configure a Docker Compose environment connecting Paperclip and Hermes to a shared Git-backed Obsidian vault using non-root user mapping (UID 1000). You will serialize repository commits using flock, build an automated pre-cleanup diff checkpoint script to protect uncommitted files from accidental deletion, and establish single-writer file boundaries across review stages. For the operational story of catching an autonomous bot deleting its own tests in real time, read When Your AI Pair Programmer Deletes Its Own Homework on Frizzle Tech Blog.
Prerequisites
Before creating the container environment, ensure your host system has Docker installed with Compose support, an existing Git repository or Obsidian vault cloned locally, and standard command line utilities available.
- A Linux host or homelab server running Docker Engine
26.xor later with Docker Compose v2. - A local Git repository or Obsidian vault cloned at
/path/to/vaultowned by your standard user account (UID 1000,GID 1000). - Container images for Paperclip (
paperclip-control-plane:latest) and Hermes (hermes-agent:latest) available locally. - Host packages
git,python3(version3.11+), andutil-linuxproviding theflockbinary.
Step 1: Configure Shared Container Mounts and User ID Mapping
To prevent container processes from writing root-owned files that lock out host users, both containers must run under your non-root user identifier (1000:1000). Create /path/to/git/agent-harness/docker-compose.yml:
services:
paperclip:
image: paperclip-control-plane:latest
container_name: paperclip-core
user: "1000:1000"
security_opt:
- no-new-privileges:true
volumes:
- /path/to/vault:/workspace/vault:rw
- /path/to/git/agent-harness:/workspace/harness:rw
- agent-run-locks:/var/run/agent-locks:rw
environment:
- VAULT_ROOT=/workspace/vault
- LOCK_DIR=/var/run/agent-locks
restart: unless-stopped
hermes:
image: hermes-agent:latest
container_name: hermes-worker
user: "1000:1000"
security_opt:
- no-new-privileges:true
volumes:
- /path/to/vault:/workspace/vault:rw
- /path/to/git/agent-harness:/workspace/harness:rw
- agent-run-locks:/var/run/agent-locks:rw
environment:
- VAULT_ROOT=/workspace/vault
- LOCK_DIR=/var/run/agent-locks
restart: unless-stopped
volumes:
agent-run-locks:
Mounting the named volume agent-run-locks provides a shared Unix domain lock directory between containers without exposing host system locks.
Step 2: Serialize Repository Operations Using flock Wrapper Scripts
When multiple agents commit to the same Git repository simultaneously, Git aborts with an index lock collision error. Wrapping all pull, stage, and commit sequences in an advisory lock prevents index contention. Create /path/to/git/agent-harness/scripts/git_sync_lock.sh:
#!/usr/bin/env bash
set -euo pipefail
LOCK_FILE="${LOCK_DIR:-/var/run/agent-locks}/vault-git.lock"
REPO_DIR="${VAULT_ROOT:-/workspace/vault}"
AGENT_NAME="${1:-autonomous-agent}"
COMMIT_MSG="${2:-chore: automated workspace update}"
mkdir -p "$(dirname "$LOCK_FILE")"
flock -w 60 "$LOCK_FILE" bash -c '
cd "'"$REPO_DIR"'"
git pull --rebase --autostash origin main
git add -A
if ! git diff --cached --quiet; then
GIT_AUTHOR_NAME="'"$AGENT_NAME"'" \
GIT_AUTHOR_EMAIL="'"$AGENT_NAME"'@local.lan" \
git commit -m "'"$COMMIT_MSG"'"
git push origin main
fi
'
Make the script executable with chmod +x /path/to/git/agent-harness/scripts/git_sync_lock.sh. The -w 60 flag instructs concurrent agent runs to wait up to sixty seconds for the active lock to clear before timing out.
Step 3: Implement Automated Pre-Cleanup Diff Checkpoints
Agents frequently execute cleanup routines after compiling binaries or running test suites. If an agent runs an overly broad git reset, uncommitted changes disappear permanently. To prevent this, build a Python pre-cleanup guard /path/to/git/agent-harness/scripts/guard_checkpoint.py:
#!/usr/bin/env python3
import datetime
import pathlib
import subprocess
import sys
VAULT_PATH = pathlib.Path(sys.argv[1] if len(sys.argv) > 1 else "/workspace/vault")
BACKUP_DIR = VAULT_PATH / ".agent_checkpoints"
def create_pre_cleanup_snapshot() -> None:
BACKUP_DIR.mkdir(parents=True, exist_ok=True)
status = subprocess.check_output(
["git", "-C", str(VAULT_PATH), "status", "--porcelain"],
text=True,
).strip()
if not status:
return
timestamp = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
diff_file = BACKUP_DIR / f"diff_{timestamp}.patch"
with open(diff_file, "w", encoding="utf-8") as handle:
subprocess.run(
["git", "-C", str(VAULT_PATH), "diff", "HEAD"],
stdout=handle,
check=True,
)
untracked_archive = BACKUP_DIR / f"untracked_{timestamp}.tar.gz"
untracked_files = [
line[3:].strip() for line in status.splitlines() if line.startswith("??")
]
if untracked_files:
cmd = ["tar", "-czf", str(untracked_archive), "-C", str(VAULT_PATH)]
cmd.extend(untracked_files)
subprocess.run(cmd, check=True)
if __name__ == "__main__":
create_pre_cleanup_snapshot()
Calling this guard prior to any reset or test teardown ensures that modified lines and untracked test files remain archived in .agent_checkpoints/ where you can retrieve them if an agent wipes its branch.
Step 4: Enforce Single-Writer Review Boundaries
To prevent race conditions during collaborative editing, structure your directory layout with strict single-writer rules. In this pattern, the lead author writes exclusively to drafts/, while review agents output critique notes into a parallel reviews/ directory without editing the author file.
/workspace/vault/
├── Notes/
│ ├── drafts/
│ │ └── 2026-12-04-agent-harness.md # Lead author write-only
│ └── reviews/
│ └── 2026-12-04-agent-harness/
│ ├── reviewer-alpha-r1.md # Reviewer 1 write-only
│ └── reviewer-beta-r1.md # Reviewer 2 write-only
You can verify writer boundaries using a lightweight pre-commit hook that inspects changed paths against the agent token name. Review agents that attempt to edit files outside reviews/ fail immediately, eliminating accidental overwrite collisions.
Hardware & Gear Used in This Guide
- Host platform: Mini-PC homelab server configured with an 8-core x86-64 processor, 32 GB DDR5 RAM, and 1 TB PCIe 4.0 NVMe SSD
- Operating system: Ubuntu Server 24.04 LTS running Linux kernel 6.8
- Container runtime: Docker Engine 27.2 with Docker Compose v2.29
- Local storage: Ext4 local filesystem with Git remote synchronization to a self-hosted GitLab server
What You Can Do Next
- Route local model requests from Hermes through an OpenAI-compatible gateway as described in Setting Up Hermes Agent Locally with a LiteLLM Router and Free Cloud Fallbacks.
- Connect container event notifications to a local messaging webhook using the maildir bridge from Setting Up a Headless Gmail-to-Maildir Sync Container on a NAS with Telegram Webhook Notifications.
- Read the companion story When Your AI Pair Programmer Deletes Its Own Homework on Frizzle Tech Blog to see how an automated review committee caught a cloud bot clobbering its own regression tests.
Later,
SteveO
