From f3e539ff137e812a8fc968a719b216375f9b555a Mon Sep 17 00:00:00 2001 From: Timor Gruber Date: Sun, 18 Oct 2026 21:06:55 +0300 Subject: [PATCH 1/4] standardize Claude signing across personal and work environments Use Ed25519 for Claude commit signing regardless of the machine's work settings. Make the launcher and sandbox profile available in personal environments as well. Remove RSA signing access and redundant multi-key loading while keeping authentication and manual GPG signing unchanged. --- .chezmoiignore | 3 --- dot_agents/shell/claude.zsh | 10 ++-------- dot_agents/shell/nono.zsh.tmpl | 7 ------- dot_claude/gitconfig.tmpl | 13 +------------ .../nono/profiles/my-claude-code.jsonc.tmpl | 2 -- 5 files changed, 3 insertions(+), 32 deletions(-) diff --git a/.chezmoiignore b/.chezmoiignore index bd2c5a7..e70b8fd 100644 --- a/.chezmoiignore +++ b/.chezmoiignore @@ -31,9 +31,6 @@ Taskfile.yml {{- if not .personal.work_env }} .work/ # only manage work state on work machines -# Work-specific Claude integration requires work SSH key names. -.agents/shell/claude.zsh -.config/nono/profiles/my-claude-code.jsonc {{- end }} {{- if not (and .personal.work_env (eq .personal.work_name "sedg")) }} diff --git a/dot_agents/shell/claude.zsh b/dot_agents/shell/claude.zsh index 8432bc4..6ac0b0c 100644 --- a/dot_agents/shell/claude.zsh +++ b/dot_agents/shell/claude.zsh @@ -2,18 +2,12 @@ function _claude_nono() { local profile="$1" shift - _nono_agent_ensure_ssh_signing_keys \ - "${CLAUDE_SSH_SIGNING_PUBLIC_KEY:-$HOME/.ssh/id_rsa.pub}" \ - "${CLAUDE_SSH_SIGNING_KEY:-$HOME/.ssh/id_rsa}" \ - "${CLAUDE_ED25519_SSH_SIGNING_PUBLIC_KEY:-$HOME/.ssh/id_ed25519.pub}" \ - "${CLAUDE_ED25519_SSH_SIGNING_KEY:-$HOME/.ssh/id_ed25519}" - _nono_agent_run \ "$profile" \ "$HOME/.claude/gitconfig" \ claude \ - "${CLAUDE_SSH_SIGNING_PUBLIC_KEY:-$HOME/.ssh/id_rsa.pub}" \ - "${CLAUDE_SSH_SIGNING_KEY:-$HOME/.ssh/id_rsa}" \ + "${CLAUDE_SSH_SIGNING_PUBLIC_KEY:-$HOME/.ssh/id_ed25519.pub}" \ + "${CLAUDE_SSH_SIGNING_KEY:-$HOME/.ssh/id_ed25519}" \ --dangerously-skip-permissions \ "$@" } diff --git a/dot_agents/shell/nono.zsh.tmpl b/dot_agents/shell/nono.zsh.tmpl index a6bb83c..57d9a02 100644 --- a/dot_agents/shell/nono.zsh.tmpl +++ b/dot_agents/shell/nono.zsh.tmpl @@ -18,13 +18,6 @@ function _nono_agent_ensure_ssh_signing_key() { {{- end }} } -function _nono_agent_ensure_ssh_signing_keys() { - while (( $# >= 2 )); do - _nono_agent_ensure_ssh_signing_key "$1" "$2" - shift 2 - done -} - function _nono_agent_run() { local profile="$1" local git_config="$2" diff --git a/dot_claude/gitconfig.tmpl b/dot_claude/gitconfig.tmpl index b0ca984..6f5797a 100644 --- a/dot_claude/gitconfig.tmpl +++ b/dot_claude/gitconfig.tmpl @@ -1,12 +1 @@ -[include] - path = {{ .chezmoi.homeDir }}/.config/git/common.gitconfig -[core] - sshCommand = {{ .chezmoi.homeDir }}/.local/bin/nono-git-ssh -[user] -{{- if and .personal.work_env (eq .personal.work_name "sedg") }} - signingkey = {{ .chezmoi.homeDir }}/.ssh/id_rsa.pub -{{- else }} - signingkey = {{ .chezmoi.homeDir }}/.ssh/id_ed25519.pub -{{- end }} -[gpg] - format = ssh +{{ template "personal-agent-gitconfig.tmpl" . -}} diff --git a/private_dot_config/nono/profiles/my-claude-code.jsonc.tmpl b/private_dot_config/nono/profiles/my-claude-code.jsonc.tmpl index 0659a63..a6bc861 100644 --- a/private_dot_config/nono/profiles/my-claude-code.jsonc.tmpl +++ b/private_dot_config/nono/profiles/my-claude-code.jsonc.tmpl @@ -25,7 +25,6 @@ ], "allow_file": [], "read_file": [ - "$HOME/.ssh/id_rsa.pub", "$HOME/.ssh/id_ed25519.pub", "$HOME/.ssh/known_hosts", "$HOME/.ssh/config", @@ -41,7 +40,6 @@ "write_file": [], "deny": [], "bypass_protection": [ - "$HOME/.ssh/id_rsa.pub", "$HOME/.ssh/id_ed25519.pub", "$HOME/.ssh/known_hosts", "$HOME/.ssh/config" From 34e650caa40162d7bb14e2370bd295a089611e46 Mon Sep 17 00:00:00 2001 From: Timor Gruber Date: Sun, 18 Oct 2026 21:07:14 +0300 Subject: [PATCH 2/4] consolidate Git configuration for coding agents Share one SSH-signing Git configuration across Claude, Codex, and OpenCode instead of maintaining identical per-agent files. Select the shared configuration in the common launcher and grant each sandbox access to it. Keep manual sessions on their existing GPG setup. --- dot_agents/shell/claude.zsh | 1 - dot_agents/shell/codex.zsh | 2 -- dot_agents/shell/nono.zsh.tmpl | 11 +++++------ dot_agents/shell/opencode.zsh | 1 - dot_claude/gitconfig.tmpl | 1 - dot_codex/gitconfig.tmpl | 1 - .../git/agent.gitconfig.tmpl | 0 .../nono/profiles/my-claude-code.jsonc.tmpl | 1 + private_dot_config/nono/profiles/my-codex.jsonc | 2 +- private_dot_config/nono/profiles/my-opencode.jsonc | 1 + private_dot_config/opencode/gitconfig.tmpl | 1 - 11 files changed, 8 insertions(+), 14 deletions(-) delete mode 100644 dot_claude/gitconfig.tmpl delete mode 100644 dot_codex/gitconfig.tmpl rename .chezmoitemplates/personal-agent-gitconfig.tmpl => private_dot_config/git/agent.gitconfig.tmpl (100%) delete mode 100644 private_dot_config/opencode/gitconfig.tmpl diff --git a/dot_agents/shell/claude.zsh b/dot_agents/shell/claude.zsh index 6ac0b0c..975d4b7 100644 --- a/dot_agents/shell/claude.zsh +++ b/dot_agents/shell/claude.zsh @@ -4,7 +4,6 @@ function _claude_nono() { _nono_agent_run \ "$profile" \ - "$HOME/.claude/gitconfig" \ claude \ "${CLAUDE_SSH_SIGNING_PUBLIC_KEY:-$HOME/.ssh/id_ed25519.pub}" \ "${CLAUDE_SSH_SIGNING_KEY:-$HOME/.ssh/id_ed25519}" \ diff --git a/dot_agents/shell/codex.zsh b/dot_agents/shell/codex.zsh index 2dc2831..942bfd1 100644 --- a/dot_agents/shell/codex.zsh +++ b/dot_agents/shell/codex.zsh @@ -12,7 +12,6 @@ function _codex() { _codex_nono_run \ "$profile" \ - "$HOME/.codex/gitconfig" \ codex \ "${CODEX_SSH_SIGNING_PUBLIC_KEY:-$HOME/.ssh/id_ed25519.pub}" \ "${CODEX_SSH_SIGNING_KEY:-$HOME/.ssh/id_ed25519}" \ @@ -28,7 +27,6 @@ function _codex_acp() { _codex_nono_run \ "$profile" \ - "$HOME/.codex/gitconfig" \ npx \ "${CODEX_SSH_SIGNING_PUBLIC_KEY:-$HOME/.ssh/id_ed25519.pub}" \ "${CODEX_SSH_SIGNING_KEY:-$HOME/.ssh/id_ed25519}" \ diff --git a/dot_agents/shell/nono.zsh.tmpl b/dot_agents/shell/nono.zsh.tmpl index 57d9a02..92aad08 100644 --- a/dot_agents/shell/nono.zsh.tmpl +++ b/dot_agents/shell/nono.zsh.tmpl @@ -20,11 +20,10 @@ function _nono_agent_ensure_ssh_signing_key() { function _nono_agent_run() { local profile="$1" - local git_config="$2" - local command_name="$3" - local public_key="$4" - local private_key="$5" - shift 5 + local command_name="$2" + local public_key="$3" + local private_key="$4" + shift 4 _nono_agent_ensure_ssh_signing_key "$public_key" "$private_key" @@ -74,7 +73,7 @@ function _nono_agent_run() { acp_args=(--silent --startup-timeout 0) fi - GIT_CONFIG_GLOBAL="$git_config" \ + GIT_CONFIG_GLOBAL="$HOME/.config/git/agent.gitconfig" \ nono run \ --profile "$profile" \ --allow-cwd \ diff --git a/dot_agents/shell/opencode.zsh b/dot_agents/shell/opencode.zsh index 06dbd35..cdc44a1 100644 --- a/dot_agents/shell/opencode.zsh +++ b/dot_agents/shell/opencode.zsh @@ -11,7 +11,6 @@ function _opencode_nono() { _nono_agent_run \ "$profile" \ - "$HOME/.config/opencode/gitconfig" \ "$command_name" \ "${OPENCODE_SSH_SIGNING_PUBLIC_KEY:-$HOME/.ssh/id_ed25519.pub}" \ "${OPENCODE_SSH_SIGNING_KEY:-$HOME/.ssh/id_ed25519}" \ diff --git a/dot_claude/gitconfig.tmpl b/dot_claude/gitconfig.tmpl deleted file mode 100644 index 6f5797a..0000000 --- a/dot_claude/gitconfig.tmpl +++ /dev/null @@ -1 +0,0 @@ -{{ template "personal-agent-gitconfig.tmpl" . -}} diff --git a/dot_codex/gitconfig.tmpl b/dot_codex/gitconfig.tmpl deleted file mode 100644 index 6f5797a..0000000 --- a/dot_codex/gitconfig.tmpl +++ /dev/null @@ -1 +0,0 @@ -{{ template "personal-agent-gitconfig.tmpl" . -}} diff --git a/.chezmoitemplates/personal-agent-gitconfig.tmpl b/private_dot_config/git/agent.gitconfig.tmpl similarity index 100% rename from .chezmoitemplates/personal-agent-gitconfig.tmpl rename to private_dot_config/git/agent.gitconfig.tmpl diff --git a/private_dot_config/nono/profiles/my-claude-code.jsonc.tmpl b/private_dot_config/nono/profiles/my-claude-code.jsonc.tmpl index a6bc861..b56e640 100644 --- a/private_dot_config/nono/profiles/my-claude-code.jsonc.tmpl +++ b/private_dot_config/nono/profiles/my-claude-code.jsonc.tmpl @@ -30,6 +30,7 @@ "$HOME/.ssh/config", "$HOME/.local/bin/nono-git-ssh", "$XDG_DATA_HOME/deck/bin/deck-claude-hook.sh", // Deck VS Code agent-management hook + "$XDG_CONFIG_HOME/git/agent.gitconfig", "$XDG_CONFIG_HOME/git/common.gitconfig", "$XDG_CONFIG_HOME/git/personal.gitconfig", // Pinned identity for the dotfiles repo "$XDG_CONFIG_HOME/git/allowed_signers", diff --git a/private_dot_config/nono/profiles/my-codex.jsonc b/private_dot_config/nono/profiles/my-codex.jsonc index 2ae6d34..d9c5b71 100644 --- a/private_dot_config/nono/profiles/my-codex.jsonc +++ b/private_dot_config/nono/profiles/my-codex.jsonc @@ -17,7 +17,7 @@ "$HOME/.ssh/known_hosts", "$HOME/.ssh/config", "$HOME/.local/bin/nono-git-ssh", - "$HOME/.codex/gitconfig" + "$XDG_CONFIG_HOME/git/agent.gitconfig" ], "bypass_protection": [ "$HOME/.ssh/id_ed25519.pub", diff --git a/private_dot_config/nono/profiles/my-opencode.jsonc b/private_dot_config/nono/profiles/my-opencode.jsonc index 1c48752..67056ac 100644 --- a/private_dot_config/nono/profiles/my-opencode.jsonc +++ b/private_dot_config/nono/profiles/my-opencode.jsonc @@ -26,6 +26,7 @@ "$HOME/.ssh/known_hosts", "$HOME/.ssh/config", "$HOME/.local/bin/nono-git-ssh", + "$XDG_CONFIG_HOME/git/agent.gitconfig", "$XDG_CONFIG_HOME/git/common.gitconfig", "$XDG_CONFIG_HOME/git/personal.gitconfig", // Pinned identity for the dotfiles repo "$XDG_CONFIG_HOME/git/allowed_signers", diff --git a/private_dot_config/opencode/gitconfig.tmpl b/private_dot_config/opencode/gitconfig.tmpl deleted file mode 100644 index 6f5797a..0000000 --- a/private_dot_config/opencode/gitconfig.tmpl +++ /dev/null @@ -1 +0,0 @@ -{{ template "personal-agent-gitconfig.tmpl" . -}} From aca8f9ec25ce9fe4bd2e7b489a1e65e54fa0b28c Mon Sep 17 00:00:00 2001 From: Timor Gruber Date: Sun, 18 Oct 2026 21:33:50 +0300 Subject: [PATCH 3/4] document shared agent Git signing Describe agent signing configuration, host setup, sandbox access, and local versus host verification for maintainers. Align the chezmoi data contract and profile-maintenance guidance with the shared configuration and launcher responsibilities. --- .../skills/managing-nono-profiles/SKILL.md | 9 +- docs/contracts/chezmoi-data.md | 6 +- docs/dotfiles/domain.md | 13 +++ .../processes/agent-commit-signing.md | 89 +++++++++++++++++++ 4 files changed, 112 insertions(+), 5 deletions(-) create mode 100644 docs/dotfiles/processes/agent-commit-signing.md diff --git a/.agents/skills/managing-nono-profiles/SKILL.md b/.agents/skills/managing-nono-profiles/SKILL.md index 67090e4..7597651 100644 --- a/.agents/skills/managing-nono-profiles/SKILL.md +++ b/.agents/skills/managing-nono-profiles/SKILL.md @@ -75,8 +75,9 @@ Use this pattern instead: - Grant exact public SSH metadata with `filesystem.read_file`. - Add the same exact public/metadata files to `filesystem.bypass_protection` when they live under denied paths like `$HOME/.ssh`. - Never add `$HOME/.ssh` as a directory grant or bypass unless explicitly requested and security-reviewed. -- Let shell wrappers preload keys into the host `ssh-agent` before entering nono. -- Let wrappers pass `--allow-unix-socket "$SSH_AUTH_SOCK"` so the sandbox can ask the host agent to sign without reading private key files. +- Use the shared `~/.config/git/agent.gitconfig` for agent Git configuration. +- Let `_nono_agent_run` attempt to preload the key into the host `ssh-agent` before entering nono. This is best-effort, not a fail-fast check; missing sockets, missing keys, or failed loads do not prevent launch. +- Let `_nono_agent_run` pass `--allow-unix-socket "$SSH_AUTH_SOCK"` when the socket variable is set, so the sandbox can ask the host agent to sign without reading private key files. Public SSH metadata commonly needed by Git: @@ -84,6 +85,8 @@ Public SSH metadata commonly needed by Git: - `$HOME/.ssh/known_hosts` - `$HOME/.ssh/config` +Profiles also need read access to the shared agent, common, and personal Git configs, `allowed_signers`, and `nono-git-ssh`. Grant the required public SSH metadata through both `read_file` and `bypass_protection`, while keeping private keys excluded. + Validate private keys remain blocked with: ```sh @@ -96,6 +99,8 @@ Expected result: `DENIED` by `deny_credentials`. Shared nono wrapper helpers live in `dot_agents/shell/nono.zsh.tmpl`. +`_nono_agent_run` owns `GIT_CONFIG_GLOBAL="$HOME/.config/git/agent.gitconfig"` for all agents. Per-agent wrappers pass the profile, command, preload key paths, and command arguments. The `OPENCODE_SSH_SIGNING_*`, `CLAUDE_SSH_SIGNING_*`, and `CODEX_SSH_SIGNING_*` environment overrides affect preloading only; they do not change Git's configured signing key. + Per-agent files should call `_nono_agent_run` instead of duplicating nono setup: - `dot_agents/shell/opencode.zsh` diff --git a/docs/contracts/chezmoi-data.md b/docs/contracts/chezmoi-data.md index c3ec76a..7ec257b 100644 --- a/docs/contracts/chezmoi-data.md +++ b/docs/contracts/chezmoi-data.md @@ -24,8 +24,8 @@ Chezmoi's built-in `.chezmoi.*` values are not part of this installer-owned cont |----------|-----------------|----------|-----------------|-------------------| | `data.personal.email` | `.personal.email` | Always | `DotfilesData.Email` | Common Git identity (non-work fallback), personal-repo override, and signer templates | | `data.personal.full_name` | `.personal.full_name` | Always | `FirstName` and `LastName`, joined with a space | Common Git identity template | -| `data.personal.work_env` | `.personal.work_env` | Always | Whether `DotfilesData.WorkEnv` is present | `.chezmoiignore`, shell templates, and work-dependent agent/Git templates | -| `data.personal.work_name` | `.personal.work_name` | Work environments only | `DotfilesWorkEnvData.WorkName` | Work profile extensions and work-dependent agent/Git templates | +| `data.personal.work_env` | `.personal.work_env` | Always | Whether `DotfilesData.WorkEnv` is present | `.chezmoiignore`, work shell templates, common Git identity, and allowed signer identities | +| `data.personal.work_name` | `.personal.work_name` | Work environments only | `DotfilesWorkEnvData.WorkName` | Work shell profile extensions and employer nono profile filtering | | `data.personal.work_email` | `.personal.work_email` | Work environments only | `DotfilesWorkEnvData.WorkEmail` | Common Git identity and signer templates (work environments) | ### `system` @@ -44,7 +44,7 @@ Chezmoi's built-in `.chezmoi.*` values are not part of this installer-owned cont ## Work-Environment Invariants -When `personal.work_env` is `false`, the installer omits `work_name`, `work_email`, and both work-profile paths. `.chezmoiignore` excludes the managed work tree and work-dependent agent configuration in that mode. +When `personal.work_env` is `false`, the installer omits `work_name`, `work_email`, and both work-profile paths. `.chezmoiignore` excludes the managed work tree and employer-specific nono profiles in that mode. When `personal.work_env` is `true`, the installer writes the work identity and both profile paths. Templates may therefore treat those conditional values as a group. The dotfile meaning of the two profile paths is documented in the [dotfiles domain][dotfiles-domain], and their runtime use is documented by [work environment loading][work-environment-loading]. diff --git a/docs/dotfiles/domain.md b/docs/dotfiles/domain.md index 8024e82..92a65af 100644 --- a/docs/dotfiles/domain.md +++ b/docs/dotfiles/domain.md @@ -42,6 +42,16 @@ private_dot_work/ **Employer-specific nono profiles:** Employer profiles live with the personal profiles in `~/.config/nono/profiles/`, named `work-{work_name}-*`. A `.chezmoiignore` block per employer skips them unless `personal.work_env` is true and `personal.work_name` matches. Each employer project has its own profile and launcher. Project profiles extend `work-{work_name}-common`, an agent-neutral profile that holds the employer's shared access (domains, credentials, tool config), plus the personal profiles they need. The launchers live in `~/.work/{work_name}/agents/shell/` and call the shared wrapper helpers from `~/.agents/shell/` with these profile names. +### Agent Git Signing + +OpenCode, Claude Code, and Codex launched through the shared nono helpers use `~/.config/git/agent.gitconfig`. The [agent Git template][agent-git-template] includes the common Git configuration, selects SSH signing with `~/.ssh/id_ed25519.pub`, and sets `core.sshCommand` to `~/.local/bin/nono-git-ssh` for Git SSH transport. + +Signing method and Git identity are separate. The [common Git template][common-git-template] selects the work email on work machines and the personal email otherwise; its repository-specific include selects the personal email for this dotfiles repository. + +The shared `_nono_agent_run` helper sets `GIT_CONFIG_GLOBAL`, attempts to preload the key into the host `ssh-agent`, and grants access to its socket. Sandboxed agents read public metadata, not private key files. Preloading is best-effort and does not guarantee that signing will succeed. Manual Git sessions use the GPG configuration in `~/.gitconfig`. + +See the [agent commit signing process][agent-commit-signing] for host setup, sandbox access, and verification. + ### Deferred Homebrew Loading A shell startup optimization pattern where Homebrew's expensive `shellenv` evaluation is postponed from `.zshenv` to `.zshrc` on macOS. This avoids the cost in non-interactive shells while keeping the environment available for interactive use. @@ -79,3 +89,6 @@ See the [shell startup process][shell-startup] for the full shell startup flow i [shell-startup]: processes/shell-startup.md [work-env-loading]: processes/work-environment-loading.md [chezmoi-data-contract]: ../contracts/chezmoi-data.md +[agent-git-template]: ../../private_dot_config/git/agent.gitconfig.tmpl +[common-git-template]: ../../private_dot_config/git/common.gitconfig.tmpl +[agent-commit-signing]: processes/agent-commit-signing.md diff --git a/docs/dotfiles/processes/agent-commit-signing.md b/docs/dotfiles/processes/agent-commit-signing.md new file mode 100644 index 0000000..0bfa9d8 --- /dev/null +++ b/docs/dotfiles/processes/agent-commit-signing.md @@ -0,0 +1,89 @@ +# Agent Commit Signing + +## Overview + +Signs Git commits from nono-launched OpenCode, Claude Code, and Codex with the host's Ed25519 key through `ssh-agent`. The [shared agent Git configuration][agent-git] selects the signing key; the [common configuration][common-git] supplies the name and email. See [agent Git signing][domain-signing] for identity selection and configuration ownership. + +## Trigger + +A coding agent starts through a shell wrapper and later runs a Git commit with signing enabled. + +## Actors + +- **Host user**: Registers the public signing key with the Git hosting account and makes the private key available to the host `ssh-agent`. +- **[Shared launcher][shared-launcher]**: Attempts key preloading, sets the agent Git config, and passes the agent socket to nono. +- **Nono profiles**: Permit public metadata and socket access without private-key reads. +- **Git and `ssh-agent`**: Request and produce the SSH signature. +- **Local Git or Git host**: Verify the signature using separate trust configuration. + +## Flow + +### Host Setup + +1. Register `~/.ssh/id_ed25519.pub` as a signing key on each Git hosting account that needs to verify its signatures. Where the host supports multiple signing keys, register each machine's public key with the account. +2. Ensure the host `ssh-agent` is available through `SSH_AUTH_SOCK` and can use the matching private key. Key loading happens on the host, before the sandbox starts; private keys are not granted to the sandbox. +3. Configure repository authentication separately. Registering a signing key does not by itself grant clone, fetch, or push access, even when the same public key is used for authentication. + +### Agent Launch and Signing + +1. The [OpenCode][opencode-wrapper], [Claude Code][claude-wrapper], or [Codex][codex-wrapper] wrapper passes its profile, command, and preload key paths to `_nono_agent_run`. The defaults are `~/.ssh/id_ed25519.pub` and `~/.ssh/id_ed25519`. +2. `_nono_agent_ensure_ssh_signing_key` checks the socket, `ssh-add`, and public key, then tests agent signing with `ssh-add -T`. If needed and readable on the host, it attempts to load the private key. On macOS it tries `--apple-use-keychain` before ordinary `ssh-add`. +3. `_nono_agent_run` launches nono with `GIT_CONFIG_GLOBAL="$HOME/.config/git/agent.gitconfig"`. If `SSH_AUTH_SOCK` is set, it adds `--allow-unix-socket "$SSH_AUTH_SOCK"`. +4. Git reads the shared agent config, which includes `common.gitconfig`, enables SSH signature format, and selects `~/.ssh/id_ed25519.pub`. The common config enables commit signing. Git asks the host agent to sign using the corresponding private key. +5. For Git SSH transport, `core.sshCommand` selects [`nono-git-ssh`][git-ssh], which uses `ncat` for proxy-aware SSH connections. This transport setting is separate from commit signing. + +Preloading is best-effort: missing prerequisites or failed key loading do not stop agent launch. The `OPENCODE_SSH_SIGNING_PUBLIC_KEY` / `OPENCODE_SSH_SIGNING_KEY`, `CLAUDE_SSH_SIGNING_PUBLIC_KEY` / `CLAUDE_SSH_SIGNING_KEY`, and `CODEX_SSH_SIGNING_PUBLIC_KEY` / `CODEX_SSH_SIGNING_KEY` overrides change only preload inputs. They do not change Git's configured `~/.ssh/id_ed25519.pub` signing key. + +### Sandbox Access + +The [OpenCode][opencode-profile], [Claude Code][claude-profile], and [Codex][codex-profile] profiles grant these exact files in both `filesystem.read_file` and `filesystem.bypass_protection`: + +- `$HOME/.ssh/id_ed25519.pub` +- `$HOME/.ssh/known_hosts` +- `$HOME/.ssh/config` + +They also allow reading the agent Git configuration and SSH transport helper, with common configuration and local signer trust available through exact-file or Git-directory grants. The launch-time socket grant permits requests to the host agent. None of these grants requires reading private key files or granting the whole `~/.ssh` directory. + +### Verification + +- **Local verification**: `common.gitconfig` sets `gpg.ssh.allowedSignersFile` to `~/.config/git/allowed_signers`. The [signer template][allowed-signers] includes available local `id_rsa.pub` and `id_ed25519.pub` keys for the personal email and, on work machines, the work email. +- **Git host verification**: The host checks its registered signing keys and account identity rules. A successful local verification does not register a key with the host or guarantee its verified status there. + +## Failure Scenarios + +| Condition | Result | +|-----------|--------| +| Socket absent, key not loaded, or preload fails | The agent still launches; a later signed commit can fail because the configured key is unavailable | +| Preload override selects a different key | Git still requests the key matching `~/.ssh/id_ed25519.pub` | +| Public metadata or socket access missing | Signing or SSH transport can fail; inspect the exact profile grants rather than exposing private keys | +| Local signer entry missing | Local verification cannot establish trust even if the host recognizes the signature | +| Signing key not registered with the host | Local verification can succeed without host verification | +| Authentication not configured | Signing can work while repository access fails | + +## State Changes + +- The host `ssh-agent` may gain a loaded key. +- The launched process and its children inherit the shared agent Git config selection. +- A successful signed commit stores an SSH signature in the repository. + +Manual Git outside these wrappers reads [`~/.gitconfig`][manual-git], which selects the installer-configured GPG key when present. + +## Dependencies + +- Rendered agent/common Git configs and nono profiles, plus a host key pair and usable `ssh-agent`. +- Host signing-key registration for host verification; local `allowed_signers` for local verification. +- SSH transport additionally requires `ncat` and separate authentication access. + +[domain-signing]: ../domain.md#agent-git-signing +[agent-git]: ../../../private_dot_config/git/agent.gitconfig.tmpl +[common-git]: ../../../private_dot_config/git/common.gitconfig.tmpl +[shared-launcher]: ../../../dot_agents/shell/nono.zsh.tmpl +[opencode-wrapper]: ../../../dot_agents/shell/opencode.zsh +[claude-wrapper]: ../../../dot_agents/shell/claude.zsh +[codex-wrapper]: ../../../dot_agents/shell/codex.zsh +[opencode-profile]: ../../../private_dot_config/nono/profiles/my-opencode.jsonc +[claude-profile]: ../../../private_dot_config/nono/profiles/my-claude-code.jsonc.tmpl +[codex-profile]: ../../../private_dot_config/nono/profiles/my-codex.jsonc +[git-ssh]: ../../../private_dot_local/bin/executable_nono-git-ssh +[allowed-signers]: ../../../private_dot_config/git/allowed_signers.tmpl +[manual-git]: ../../../dot_gitconfig.tmpl From d23100f656dbc80325b88e4bb35e50dc7e2adcf5 Mon Sep 17 00:00:00 2001 From: Timor Gruber Date: Mon, 19 Oct 2026 00:38:49 +0300 Subject: [PATCH 4/4] select work Git identity by repository remote Default to the personal email on every machine and select the work email for SolarEdge GitLab and Azure DevOps remotes. This removes the machine-wide work default and the dotfiles path exception. Allow sandboxed agents to read the work identity configuration and document the URL matching rules without changing signing methods. --- .../skills/managing-nono-profiles/SKILL.md | 2 +- .chezmoiignore | 1 + docs/contracts/chezmoi-data.md | 10 ++++----- docs/dotfiles/domain.md | 4 +++- .../processes/agent-commit-signing.md | 8 ++++++- private_dot_config/git/common.gitconfig.tmpl | 22 +++++++++++++++---- .../git/personal.gitconfig.tmpl | 2 +- private_dot_config/git/work.gitconfig.tmpl | 3 +++ .../nono/profiles/my-claude-code.jsonc.tmpl | 3 ++- .../nono/profiles/my-opencode.jsonc | 3 ++- 10 files changed, 43 insertions(+), 15 deletions(-) create mode 100644 private_dot_config/git/work.gitconfig.tmpl diff --git a/.agents/skills/managing-nono-profiles/SKILL.md b/.agents/skills/managing-nono-profiles/SKILL.md index 7597651..da5eb25 100644 --- a/.agents/skills/managing-nono-profiles/SKILL.md +++ b/.agents/skills/managing-nono-profiles/SKILL.md @@ -85,7 +85,7 @@ Public SSH metadata commonly needed by Git: - `$HOME/.ssh/known_hosts` - `$HOME/.ssh/config` -Profiles also need read access to the shared agent, common, and personal Git configs, `allowed_signers`, and `nono-git-ssh`. Grant the required public SSH metadata through both `read_file` and `bypass_protection`, while keeping private keys excluded. +Profiles also need read access to the shared agent, common, and personal Git configs, the work Git config on work machines, `allowed_signers`, and `nono-git-ssh`. Grant the required public SSH metadata through both `read_file` and `bypass_protection`, while keeping private keys excluded. Validate private keys remain blocked with: diff --git a/.chezmoiignore b/.chezmoiignore index e70b8fd..3f4a8a7 100644 --- a/.chezmoiignore +++ b/.chezmoiignore @@ -31,6 +31,7 @@ Taskfile.yml {{- if not .personal.work_env }} .work/ # only manage work state on work machines +.config/git/work.gitconfig {{- end }} {{- if not (and .personal.work_env (eq .personal.work_name "sedg")) }} diff --git a/docs/contracts/chezmoi-data.md b/docs/contracts/chezmoi-data.md index 7ec257b..7b2d067 100644 --- a/docs/contracts/chezmoi-data.md +++ b/docs/contracts/chezmoi-data.md @@ -22,11 +22,11 @@ Chezmoi's built-in `.chezmoi.*` values are not part of this installer-owned cont | TOML key | Template access | Presence | Producer source | Current consumers | |----------|-----------------|----------|-----------------|-------------------| -| `data.personal.email` | `.personal.email` | Always | `DotfilesData.Email` | Common Git identity (non-work fallback), personal-repo override, and signer templates | +| `data.personal.email` | `.personal.email` | Always | `DotfilesData.Email` | Common Git personal-email fallback and signer templates | | `data.personal.full_name` | `.personal.full_name` | Always | `FirstName` and `LastName`, joined with a space | Common Git identity template | -| `data.personal.work_env` | `.personal.work_env` | Always | Whether `DotfilesData.WorkEnv` is present | `.chezmoiignore`, work shell templates, common Git identity, and allowed signer identities | +| `data.personal.work_env` | `.personal.work_env` | Always | Whether `DotfilesData.WorkEnv` is present | `.chezmoiignore`, work shell templates, work Git identity, and allowed signer identities | | `data.personal.work_name` | `.personal.work_name` | Work environments only | `DotfilesWorkEnvData.WorkName` | Work shell profile extensions and employer nono profile filtering | -| `data.personal.work_email` | `.personal.work_email` | Work environments only | `DotfilesWorkEnvData.WorkEmail` | Common Git identity and signer templates (work environments) | +| `data.personal.work_email` | `.personal.work_email` | Work environments only | `DotfilesWorkEnvData.WorkEmail` | Work Git identity and signer templates (work environments) | ### `system` @@ -44,9 +44,9 @@ Chezmoi's built-in `.chezmoi.*` values are not part of this installer-owned cont ## Work-Environment Invariants -When `personal.work_env` is `false`, the installer omits `work_name`, `work_email`, and both work-profile paths. `.chezmoiignore` excludes the managed work tree and employer-specific nono profiles in that mode. +When `personal.work_env` is `false`, the installer omits `work_name`, `work_email`, and both work-profile paths. `.chezmoiignore` excludes the managed work tree, employer-specific nono profiles, and the work Git configuration in that mode. -When `personal.work_env` is `true`, the installer writes the work identity and both profile paths. Templates may therefore treat those conditional values as a group. The dotfile meaning of the two profile paths is documented in the [dotfiles domain][dotfiles-domain], and their runtime use is documented by [work environment loading][work-environment-loading]. +When `personal.work_env` is `true`, the installer writes the work identity and both profile paths. The work Git configuration overrides the common personal-email fallback only for matching configured GitLab and Azure DevOps repository URLs. Templates may therefore treat the conditional values as a group. The dotfile meaning of the two profile paths is documented in the [dotfiles domain][dotfiles-domain], and their runtime use is documented by [work environment loading][work-environment-loading]. ## GPG Signing Key diff --git a/docs/dotfiles/domain.md b/docs/dotfiles/domain.md index 92a65af..bd2ba14 100644 --- a/docs/dotfiles/domain.md +++ b/docs/dotfiles/domain.md @@ -46,7 +46,9 @@ private_dot_work/ OpenCode, Claude Code, and Codex launched through the shared nono helpers use `~/.config/git/agent.gitconfig`. The [agent Git template][agent-git-template] includes the common Git configuration, selects SSH signing with `~/.ssh/id_ed25519.pub`, and sets `core.sshCommand` to `~/.local/bin/nono-git-ssh` for Git SSH transport. -Signing method and Git identity are separate. The [common Git template][common-git-template] selects the work email on work machines and the personal email otherwise; its repository-specific include selects the personal email for this dotfiles repository. +Signing method and Git identity are separate. The [common Git template][common-git-template] sets the shared name, personal email, and `user.useConfigOnly=true`. On work machines, conditional includes override the personal email with the work identity for configured GitLab and Azure DevOps repository URLs. These rules examine every remote, not only `origin`. + +Unmatched repositories, including repositories without remotes, use the personal email. Existing repository-local settings and environment overrides still take precedence. URL spelling and SSH aliases affect matching. Identity here means Git authorship metadata, not signing or repository authentication. The conditional includes require Git 2.36 or later and must not define remote URLs. The shared `_nono_agent_run` helper sets `GIT_CONFIG_GLOBAL`, attempts to preload the key into the host `ssh-agent`, and grants access to its socket. Sandboxed agents read public metadata, not private key files. Preloading is best-effort and does not guarantee that signing will succeed. Manual Git sessions use the GPG configuration in `~/.gitconfig`. diff --git a/docs/dotfiles/processes/agent-commit-signing.md b/docs/dotfiles/processes/agent-commit-signing.md index 0bfa9d8..95ccb60 100644 --- a/docs/dotfiles/processes/agent-commit-signing.md +++ b/docs/dotfiles/processes/agent-commit-signing.md @@ -2,7 +2,7 @@ ## Overview -Signs Git commits from nono-launched OpenCode, Claude Code, and Codex with the host's Ed25519 key through `ssh-agent`. The [shared agent Git configuration][agent-git] selects the signing key; the [common configuration][common-git] supplies the name and email. See [agent Git signing][domain-signing] for identity selection and configuration ownership. +Signs Git commits from nono-launched OpenCode, Claude Code, and Codex with the host's Ed25519 key through `ssh-agent`. The [shared agent Git configuration][agent-git] selects the signing key, while the [common configuration][common-git] supplies the shared name and personal-email fallback. See [agent Git signing][domain-signing] for identity selection and configuration ownership. ## Trigger @@ -34,6 +34,12 @@ A coding agent starts through a shell wrapper and later runs a Git commit with s Preloading is best-effort: missing prerequisites or failed key loading do not stop agent launch. The `OPENCODE_SSH_SIGNING_PUBLIC_KEY` / `OPENCODE_SSH_SIGNING_KEY`, `CLAUDE_SSH_SIGNING_PUBLIC_KEY` / `CLAUDE_SSH_SIGNING_KEY`, and `CODEX_SSH_SIGNING_PUBLIC_KEY` / `CODEX_SSH_SIGNING_KEY` overrides change only preload inputs. They do not change Git's configured `~/.ssh/id_ed25519.pub` signing key. +### Identity Selection + +The common configuration sets the personal email and `user.useConfigOnly=true`. On work machines, conditional includes override it with the work email for GitLab `gitlab.solaredge.com`, Azure SSH `ssh.dev.azure.com`, and Azure HTTP(S) `dev.azure.com` URLs. Any remote can match; Git does not limit the check to `origin`. + +Repositories that do not match, including those without remotes, use the personal email. Repository-local settings and environment overrides still take precedence. URL spelling and SSH aliases affect matching, and Git 2.36 or later is required. These identity rules do not change GPG or SSH signing methods, signing keys, or repository authentication. Conditional configuration files select identity only; they must not define remote URLs. + ### Sandbox Access The [OpenCode][opencode-profile], [Claude Code][claude-profile], and [Codex][codex-profile] profiles grant these exact files in both `filesystem.read_file` and `filesystem.bypass_protection`: diff --git a/private_dot_config/git/common.gitconfig.tmpl b/private_dot_config/git/common.gitconfig.tmpl index dd2e0b3..5666b0c 100644 --- a/private_dot_config/git/common.gitconfig.tmpl +++ b/private_dot_config/git/common.gitconfig.tmpl @@ -1,6 +1,7 @@ [user] name = {{ .personal.full_name }} - email = {{ if and .personal.work_env .personal.work_email }}{{ .personal.work_email }}{{ else }}{{ .personal.email }}{{ end }} + email = {{ .personal.email }} + useConfigOnly = true [branch] sort = committerdate [pull] @@ -37,6 +38,19 @@ gpgSign = true [gpg "ssh"] allowedSignersFile = {{ .chezmoi.homeDir }}/.config/git/allowed_signers -{{- /* This dotfiles repo commits under the personal identity, even on work machines. */}} -[includeIf "gitdir:{{ .chezmoi.sourceDir }}/"] - path = {{ .chezmoi.homeDir }}/.config/git/personal.gitconfig +{{ if .personal.work_env -}} +{{ range $host := list "gitlab.solaredge.com" "ssh.dev.azure.com" -}} +[includeIf "hasconfig:remote.*.url:*@{{ $host }}:*/**"] + path = {{ $.chezmoi.homeDir }}/.config/git/work.gitconfig +[includeIf "hasconfig:remote.*.url:ssh://*@{{ $host }}/**"] + path = {{ $.chezmoi.homeDir }}/.config/git/work.gitconfig +{{ end -}} +{{ range $host := list "gitlab.solaredge.com" "dev.azure.com" -}} +{{ range $scheme := list "https" "http" -}} +[includeIf "hasconfig:remote.*.url:{{ $scheme }}://{{ $host }}/**"] + path = {{ $.chezmoi.homeDir }}/.config/git/work.gitconfig +[includeIf "hasconfig:remote.*.url:{{ $scheme }}://*@{{ $host }}/**"] + path = {{ $.chezmoi.homeDir }}/.config/git/work.gitconfig +{{ end -}} +{{ end -}} +{{ end -}} diff --git a/private_dot_config/git/personal.gitconfig.tmpl b/private_dot_config/git/personal.gitconfig.tmpl index 2c3a5e4..ebcd4e6 100644 --- a/private_dot_config/git/personal.gitconfig.tmpl +++ b/private_dot_config/git/personal.gitconfig.tmpl @@ -1,3 +1,3 @@ -# Managed by chezmoi. Overrides the git identity to personal for the dotfiles repo. +# Managed by chezmoi. Selects the personal identity for matching repository remotes. [user] email = {{ .personal.email }} diff --git a/private_dot_config/git/work.gitconfig.tmpl b/private_dot_config/git/work.gitconfig.tmpl new file mode 100644 index 0000000..91235c0 --- /dev/null +++ b/private_dot_config/git/work.gitconfig.tmpl @@ -0,0 +1,3 @@ +# Managed by chezmoi. Selects the work identity for matching repository remotes. +[user] + email = {{ if .personal.work_env }}{{ .personal.work_email }}{{ end }} diff --git a/private_dot_config/nono/profiles/my-claude-code.jsonc.tmpl b/private_dot_config/nono/profiles/my-claude-code.jsonc.tmpl index b56e640..ddcfb50 100644 --- a/private_dot_config/nono/profiles/my-claude-code.jsonc.tmpl +++ b/private_dot_config/nono/profiles/my-claude-code.jsonc.tmpl @@ -32,7 +32,8 @@ "$XDG_DATA_HOME/deck/bin/deck-claude-hook.sh", // Deck VS Code agent-management hook "$XDG_CONFIG_HOME/git/agent.gitconfig", "$XDG_CONFIG_HOME/git/common.gitconfig", - "$XDG_CONFIG_HOME/git/personal.gitconfig", // Pinned identity for the dotfiles repo + "$XDG_CONFIG_HOME/git/personal.gitconfig", + "$XDG_CONFIG_HOME/git/work.gitconfig", "$XDG_CONFIG_HOME/git/allowed_signers", "$XDG_CONFIG_HOME/worktrunk/config.toml", "$XDG_CONFIG_HOME/gh/config.yml", diff --git a/private_dot_config/nono/profiles/my-opencode.jsonc b/private_dot_config/nono/profiles/my-opencode.jsonc index 67056ac..1260e74 100644 --- a/private_dot_config/nono/profiles/my-opencode.jsonc +++ b/private_dot_config/nono/profiles/my-opencode.jsonc @@ -28,7 +28,8 @@ "$HOME/.local/bin/nono-git-ssh", "$XDG_CONFIG_HOME/git/agent.gitconfig", "$XDG_CONFIG_HOME/git/common.gitconfig", - "$XDG_CONFIG_HOME/git/personal.gitconfig", // Pinned identity for the dotfiles repo + "$XDG_CONFIG_HOME/git/personal.gitconfig", + "$XDG_CONFIG_HOME/git/work.gitconfig", "$XDG_CONFIG_HOME/git/allowed_signers", "$XDG_CONFIG_HOME/worktrunk/config.toml", "$XDG_CONFIG_HOME/gh/config.yml",