The bot’s repo is its memory. The harness keeps it in sync with the remote automatically, so the brain is continuously backed up and (optionally) shared across machines.
autosync in src/commands/sync.ts, every minute): if the
working tree has changes, commit them, then push. If the push is rejected
because the remote advanced, fetch + rebase --autostash local commits on
top and push again (bounded retries).watchdogSyncRepo, same file): same commit, then rebase onto
origin/<branch>, then push, before relaunching the agent — so each launch
starts from the latest.Both operate on BOT_DIR (the bot’s folder), never on the harness checkout, and
both are skipped when BOT_DIR isn’t a git repo or GIT_SYNC=off (what seeyourai bot new
sets in an existing folder or a clone, unless asked). Without an origin, changes are
committed and nothing is pushed; an origin that was there and is gone is a failed push
(removed on purpose: delete .watchdog/HAD_REMOTE). The tick half
needs the cron line (seeyourai install-cron).
If you run one bot instance (the norm), there’s a single writer, so pushes almost never collide and the rebase path rarely triggers. The conflict machinery below is a safety net for the occasional second writer — e.g. a backup/cloud session you start when the main box is offline (see below).
Rebase resolves anything except the same lines edited on both sides. The dumb cron must never guess a semantic merge — a wrong silent merge on the main branch is worse than stopping. So on a true conflict, autosync:
.watchdog/RECONCILE_NEEDED.Then the reconcile check (also on the tick) injects a one-shot prompt into the live agent session, which can do a real semantic merge: it re-runs the rebase, resolves conflicted files by understanding both sides’ intent (a brain repo is mostly prose — usually keep/merge both), pushes, clears the flags, and notifies you with a summary so a human stays the backstop.
While a reconcile is in flight (.watchdog/RECONCILE_INPROGRESS), autosync skips
its tick so the agent owns the working tree — no git race.
Because the brain is just a git repo, you can run a backup session elsewhere (the Claude Code app/web, or another box) when the main instance is down. The rule is single-writer at a time: don’t run two live instances pushing to the same branch simultaneously. If you do briefly overlap, the rebase + reconcile path above converges them — non-overlapping edits merge automatically; only same-line edits pause for the agent to resolve.
If the brain is git-crypt encrypted (recommended for a personal brain — see PRIVACY.md), any backup machine also needs the key to read anything.
.watchdog/, gitignored)| File | Meaning |
|---|---|
harness.log |
the bot’s log: watchdog, sync and schedule lines (seeyourai bot logs <bot>) |
PUSH_FAILED |
commits are not reaching the remote |
HAD_REMOTE, NO_REMOTE |
it has had an origin; it never had one, and the log said so |
RECONCILE_NEEDED |
a conflict was flagged for the agent to resolve |
RECONCILE_INPROGRESS |
the agent is resolving it now (autosync stands down) |