Skip to content

Sonny: back up memory, skills, profiles and config to a git repo - #417

Merged
lydakis merged 6 commits into
mainfrom
claude/project-thread-dgjq64
Oct 30, 2026
Merged

lydakis merged 6 commits into
mainfrom
claude/project-thread-dgjq64

Conversation

@lydakis

@lydakis lydakis commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

What

A machine that may be rebuilt or lost (a cloud box, say) should hold nothing the person cannot lose. This adds a git backup of the person's home:

  • sonny setup backup [URL] clones a private repo to ~/agent-home. It installs a job, me.lydakis.agent.backup, as a LaunchAgent on a Mac and a systemd user timer on Linux, then runs the first sync.
  • sonny home sync is what the job runs every 10 minutes. It mirrors ~/.agents (memory, skills, profiles) and ~/.agent/config.toml into the repo, then commits and pushes only when something changed or is unpushed.
  • sonny home status reports whether backup is set up and how the last sync went, from ~/.agent/sonny/home.json.
  • Restore: on a machine that never synced, setup first restores what the repo already holds. A config.toml it replaces is kept as config.toml.before-restore. A new box is install.sh, then sonny setup backup URL.
  • Kept out:
    • keys in ~/.agent/env, logins and the store
    • .git, .lock, .reads and .cleanup at any depth
    • a config.toml that holds a secret itself: an MCP server's http_headers, or a string under a key named like a token, key, secret or password. The sync names the key and leaves the file behind, while memory still goes.
  • Memory's own .git is never committed into. memory changed compares git status with HEAD, so an outside commit there would make the nightly cleanup skip.
  • The job runs git with the login shell's environment, so pushes use the person's SSH agent and credential helpers.
  • At Sonny's start, a job whose definition names an older Sonny is rewritten, as triggers are.
  • home::done() is the check for the onboarding thread's upgrade setup steps, which list backup as one step. That mechanism is a separate PR.

The job reuses trigger::schedule, so the systemd timer is written from the service's [X-Timer] section the same way triggers are. trigger::escape, trigger::quoted and setup::line become pub(crate).

Checks

  • cargo test -p sonny home::: 6 new tests cover the mirror rules, secret detection, push to a bare remote, no-op resync, restore on a second machine, a refused second repo, a held-back config, backup_unset, and both job definitions.
  • cargo clippy -p sonny --all-targets and cargo fmt --check: clean.
  • I ran it by hand on Linux with a temp HOME and a local bare repo: setup, status, a second sync with no commit, restore into a second HOME, and refusal of another URL. This container has no systemd user manager, so loading the timer failed with triggers_unsupported. Setup then says it backed up once and leaves backup not set up. The timer and the LaunchAgent have not been loaded on a real machine yet.

Design doc: https://claude.ai/artifact/HhFVKQs5kt3ssZdpCrD9Lc

`sonny setup backup URL` clones a private repository to ~/agent-home and
installs a LaunchAgent or systemd user timer that runs `sonny home sync`
every ten minutes: ~/.agents and ~/.agent/config.toml are mirrored in,
committed and pushed. Keys, logins and the store stay out, as does a
config.toml holding a literal secret and memory's own .git (a commit
there would make the nightly cleanup find nothing). On a machine that
never synced, setup first restores what the repository holds, so a new
box is install.sh, then `sonny setup backup URL`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGHNP4M3xCodvaVM2fF
@lydakis lydakis self-assigned this Oct 30, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T03:52:02.214420Z 38b4e70 New commits
🔒 Security Review ✅ Completed 2026-10-30T03:56:16.981639Z 38b4e70 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f3c98331bd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sonny/src/home.rs Resolved
Comment thread sonny/src/home.rs Resolved
Comment thread sonny/src/home.rs Resolved
Comment thread sonny/src/home.rs Resolved
Comment thread sonny/src/home.rs Resolved
…catch more secrets

A sync that failed (one tried before setup) no longer stops setup from
restoring; config restores without agents/; a link that became a file is
copied as one; restored and backed-up files drop group and other bits;
private keys and credentials count as secrets.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGHNP4M3xCodvaVM2fF

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 988173f3d3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sonny/src/home.rs Resolved
Comment thread sonny/src/home.rs Resolved

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: db75082b03

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread sonny/src/home.rs Resolved
Comment thread sonny/src/home.rs Resolved
@lydakis
lydakis merged commit 738ab43 into main Oct 30, 2026
4 checks passed
lydakis added a commit that referenced this pull request Oct 30, 2026
…#437)

* Sonny: back up memory, skills, profiles and config to a git repo

`sonny setup backup URL` clones a private repository to ~/agent-home and
installs a LaunchAgent or systemd user timer that runs `sonny home sync`
every ten minutes: ~/.agents and ~/.agent/config.toml are mirrored in,
committed and pushed. Keys, logins and the store stay out, as does a
config.toml holding a literal secret and memory's own .git (a commit
there would make the nightly cleanup find nothing). On a machine that
never synced, setup first restores what the repository holds, so a new
box is install.sh, then `sonny setup backup URL`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGHNP4M3xCodvaVM2fF

* FEATURES: the backup row names #417

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGHNP4M3xCodvaVM2fF

* Backup: restore unless a sync went through, keep copies private, and catch more secrets

A sync that failed (one tried before setup) no longer stops setup from
restoring; config restores without agents/; a link that became a file is
copied as one; restored and backed-up files drop group and other bits;
private keys and credentials count as secrets.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGHNP4M3xCodvaVM2fF

* Backup: the job keeps HOME, SHELL and PATH, and copies follow the source's owner bits

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGHNP4M3xCodvaVM2fF

* Backup: git ignores none of the person's global rules, and argument lists are checked for secrets

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGHNP4M3xCodvaVM2fF

* Sonny: an upgrade offers backup, and the lead makes the private repository where this machine keeps its own

Sonny names no host. The step tells the lead to find where this machine
keeps repositories (its checkouts' remotes, the tools signed in, what the
person's other agents made) and make a private one there, then run
`sonny setup backup URL`. It is done once a repository and the job are set.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGHNP4M3xCodvaVM2fF

* FEATURES: the backup row names #429

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGHNP4M3xCodvaVM2fF

* Sonny: over SSH with no display, what it would open is copied instead

On a box reached over SSH, xdg-open (or open on a Mac) starts the browser
on the box's own screen, or nowhere, and Sonny said nothing. With
SSH_CONNECTION or SSH_TTY set and no DISPLAY, WAYLAND_DISPLAY or BROWSER,
the link, file or page now goes on the clipboard (OSC 52 reaches the
person's terminal) and the notice says so, as gh and other CLIs print a
URL they cannot open. A forwarded display or a BROWSER of the person's
still opens.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGHNP4M3xCodvaVM2fF

* FEATURES: the links row names #437

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGHNP4M3xCodvaVM2fF

---------

Co-authored-by: Claude <[email protected]>
lydakis added a commit that referenced this pull request Oct 30, 2026
* Sonny: back up memory, skills, profiles and config to a git repo

`sonny setup backup URL` clones a private repository to ~/agent-home and
installs a LaunchAgent or systemd user timer that runs `sonny home sync`
every ten minutes: ~/.agents and ~/.agent/config.toml are mirrored in,
committed and pushed. Keys, logins and the store stay out, as does a
config.toml holding a literal secret and memory's own .git (a commit
there would make the nightly cleanup find nothing). On a machine that
never synced, setup first restores what the repository holds, so a new
box is install.sh, then `sonny setup backup URL`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGHNP4M3xCodvaVM2fF

* FEATURES: the backup row names #417

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGHNP4M3xCodvaVM2fF

* Backup: restore unless a sync went through, keep copies private, and catch more secrets

A sync that failed (one tried before setup) no longer stops setup from
restoring; config restores without agents/; a link that became a file is
copied as one; restored and backed-up files drop group and other bits;
private keys and credentials count as secrets.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGHNP4M3xCodvaVM2fF

* Backup: the job keeps HOME, SHELL and PATH, and copies follow the source's owner bits

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGHNP4M3xCodvaVM2fF

* Backup: git ignores none of the person's global rules, and argument lists are checked for secrets

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGHNP4M3xCodvaVM2fF

* Sonny: an upgrade offers backup, and the lead makes the private repository where this machine keeps its own

Sonny names no host. The step tells the lead to find where this machine
keeps repositories (its checkouts' remotes, the tools signed in, what the
person's other agents made) and make a private one there, then run
`sonny setup backup URL`. It is done once a repository and the job are set.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGHNP4M3xCodvaVM2fF

* FEATURES: the backup row names #429

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGHNP4M3xCodvaVM2fF

* Sonny: over SSH with no display, what it would open is copied instead

On a box reached over SSH, xdg-open (or open on a Mac) starts the browser
on the box's own screen, or nowhere, and Sonny said nothing. With
SSH_CONNECTION or SSH_TTY set and no DISPLAY, WAYLAND_DISPLAY or BROWSER,
the link, file or page now goes on the clipboard (OSC 52 reaches the
person's terminal) and the notice says so, as gh and other CLIs print a
URL they cannot open. A forwarded display or a BROWSER of the person's
still opens.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGHNP4M3xCodvaVM2fF

* FEATURES: the links row names #437

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGHNP4M3xCodvaVM2fF

* Sonny: [sonny] start_at_boot starts the daemon with the machine

Off by default. On (in /config), Sonny keeps a job that runs `sonny boot`,
which starts the daemon as a trigger's fire does, with the login shell's
environment: a LaunchAgent run at load on a Mac (at login), or a systemd
user oneshot wanted by default.target elsewhere, which starts at boot once
the user lingers. Sonny runs `loginctl enable-linger` and says when that
needs sudo. The oneshot's daemon runs in a scope of its own, so it outlives
the service, and the daemon brings back its companions. Turning it off
removes the job and leaves a running daemon running. Sonny's start
rewrites the job when Sonny has moved, and sets it up or takes it away when
config.toml was edited by hand.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGHNP4M3xCodvaVM2fF

* FEATURES: the start-at-boot row names #441

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013jkdGHNP4M3xCodvaVM2fF

---------

Co-authored-by: Claude <[email protected]>
@lydakis lydakis mentioned this pull request Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants