From d25015bc9d9bc00e6d0f3d0ab69efda44e8c3951 Mon Sep 17 00:00:00 2001 From: m3ta-chiron Date: Sun, 1 Nov 2026 13:14:02 +0100 Subject: [PATCH] fix(t3code): run T3 agents as m3ta-chiron on every host The identity lived in the m3-hermes service and in home-manager session variables. Neither reaches the T3 desktop app on m3-kratos, so its agents committed and pushed as m3tam3re. Wrap the T3 packages via an overlay so everything T3 spawns inherits commit identity and Gitea push auth, independent of host and launcher. Co-Authored-By: Claude Opus 5.5 --- hosts/common/default.nix | 2 + hosts/m3-hermes/services/t3code.nix | 44 +++++++------------- overlays/default.nix | 64 +++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 30 deletions(-) diff --git a/hosts/common/default.nix b/hosts/common/default.nix index 8a6021d..8eebf0f 100644 --- a/hosts/common/default.nix +++ b/hosts/common/default.nix @@ -49,6 +49,8 @@ # with allowUnfree). Do NOT flatten to top-level attrs — see # overlays/default.nix. inputs.llm-agents.overlays.shared-nixpkgs + # Wraps pkgs.llm-agents.t3code* with the agents' m3ta-chiron identity. + outputs.overlays.t3code-agent-identity # You can also add overlays exported from other flakes: # neovim-nightly-overlay.overlays.default diff --git a/hosts/m3-hermes/services/t3code.nix b/hosts/m3-hermes/services/t3code.nix index cd2b2c5..c57c7c7 100644 --- a/hosts/m3-hermes/services/t3code.nix +++ b/hosts/m3-hermes/services/t3code.nix @@ -16,12 +16,12 @@ # so no deploy token) into ~/.agents/skills + ~/.config/opencode/*. A # path unit mirrors skills into ~/.claude/skills for Claude Code # (port of m3ta-home profiles/sets/coding/agents/claude-skills.nix). -# - Git identity: every harness spawned by `t3 serve` commits as the -# m3ta-chiron bot account — via service env vars, deliberately NOT via -# ~/.gitconfig, so m3tam3re's interactive git on this host is untouched. +# - Git identity and Gitea push auth: m3ta-chiron for every harness spawned +# by T3, baked into the package (overlays/default.nix, +# t3code-agent-identity), so m3tam3re's interactive git is untouched. # - Gitea SSH: m3tam3re's ssh config pins User gitea + key ~/.ssh/gitea -# (one-time keygen; pubkey added to the m3ta-chiron account) — covers -# git remotes AND git+ssh:// flake inputs. Host key pinned system-wide. +# (one-time keygen; pubkey added to the m3ta-chiron account) for +# interactive use and git+ssh:// flake inputs. Host key pinned system-wide. # # One-time interactive steps after deploy (deliberately NOT declarative — # subscription auth must live in each harness's own credential store and @@ -53,16 +53,6 @@ cockpitUser = "m3tam3re"; cockpitHome = "/home/${cockpitUser}"; - # Commit identity of the T3 Code agents: the fleet bot account. Env - # vars are respected by git in every process the service spawns; they - # survive restarts and stay out of m3tam3re's dotfiles. - gitIdentityEnv = { - GIT_AUTHOR_NAME = "m3ta-chiron"; - GIT_AUTHOR_EMAIL = "m3ta-chiron@agentmail.to"; - GIT_COMMITTER_NAME = "m3ta-chiron"; - GIT_COMMITTER_EMAIL = "m3ta-chiron@agentmail.to"; - }; - # SSH to the private Gitea for the T3 lane. Sits in m3tam3re's ssh # config (per-user — Hermes' own gitea access via its own ssh config # is unaffected). URL-embedded users (gitea@code.m3ta.dev) match the @@ -135,21 +125,13 @@ in { RestartSec = "5"; }; - environment = - { - T3CODE_PORT = toString port; - # Deterministic service context: HOME explicit so ssh/git resolve - # ~ in every process this service spawns, however deep t3's - # pty/sandbox chain resets the environment. - HOME = cockpitHome; - # Independent of HOME entirely: git uses exactly this ssh config - # (absolute store path) for every gitea remote. - GIT_SSH_COMMAND = "ssh -F ${t3SshConfig}"; - # bd falls back to git's user.name for its audit trail, which would - # be m3tam3re here — keep it in line with the commit identity. - BEADS_ACTOR = gitIdentityEnv.GIT_AUTHOR_NAME; - } - // gitIdentityEnv; + environment = { + T3CODE_PORT = toString port; + # Deterministic service context: HOME explicit so tools resolve ~ in + # every process this service spawns, however deep t3's pty/sandbox + # chain resets the environment. + HOME = cockpitHome; + }; # Harness CLIs, git and the issue tracker for the agents T3 Code spawns. path = with pkgs; [ @@ -176,6 +158,8 @@ in { systemd.tmpfiles.rules = [ "d ${cockpitHome}/.ssh 0700 ${cockpitUser} users -" "L+ ${cockpitHome}/.ssh/config - - - - ${t3SshConfig}" + # The fleet-wide key path the T3 package expects (see t3code-agent-identity). + "L+ ${cockpitHome}/.ssh/m3ta-chiron - - - - ${cockpitHome}/.ssh/gitea" ]; # ── agent-lib v2 client: skills/commands/agents for the harnesses ──── diff --git a/overlays/default.nix b/overlays/default.nix index df5e9c4..f2f8861 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -74,6 +74,70 @@ opencode-desktop = final.llm-agents.opencode2-desktop; }; + # T3 Code agents act as the m3ta-chiron bot on every host. Baked into the + # T3 packages rather than a session or service: everything T3 spawns + # inherits it, however T3 was launched (desktop launcher, systemd, shell), + # and any host installing T3 gets it. Must come AFTER shared-nixpkgs. + # + # Push auth needs ~/.ssh/m3ta-chiron on each host, with its pubkey on the + # m3ta-chiron Gitea account. A missing key fails the push instead of falling + # back to a personal key. Other hosts keep the user's own ssh config. + t3code-agent-identity = final: prev: let + identity = { + name = "m3ta-chiron"; + email = "m3ta-chiron@agentmail.to"; + }; + + giteaKnownHosts = final.writeText "gitea-known-hosts" '' + code.m3ta.dev ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFmmqZ4GgDEXJgj8uYrZAr/EoLIA6LJGkTIyKGQD/60a + ''; + + # ssh expands ~ from passwd, so this does not depend on $HOME. + sshConfig = final.writeText "t3-agent-ssh-config" '' + Host code.m3ta.dev + User gitea + IdentityFile ~/.ssh/m3ta-chiron + IdentitiesOnly yes + UserKnownHostsFile ${giteaKnownHosts} + + # Conditional: IdentityFile accumulates across matching blocks, so a + # personal code.m3ta.dev entry must not be read for this host. + Host * !code.m3ta.dev + Include ~/.ssh/config + ''; + + wrapperArgs = final.lib.concatStringsSep " " (final.lib.mapAttrsToList (name: value: "--set ${name} ${final.lib.escapeShellArg value}") { + GIT_AUTHOR_NAME = identity.name; + GIT_AUTHOR_EMAIL = identity.email; + GIT_COMMITTER_NAME = identity.name; + GIT_COMMITTER_EMAIL = identity.email; + JJ_USER = identity.name; + JJ_EMAIL = identity.email; + # bd otherwise falls back to the user's git user.name for its audit trail. + BEADS_ACTOR = identity.name; + GIT_SSH_COMMAND = "${final.openssh}/bin/ssh -F ${sshConfig}"; + }); + + wrapT3 = package: + final.symlinkJoin { + inherit (package) name meta passthru; + paths = [package]; + nativeBuildInputs = [final.makeWrapper]; + postBuild = '' + for program in $out/bin/*; do + wrapProgram "$program" ${wrapperArgs} + done + ''; + }; + in { + llm-agents = + prev.llm-agents + // { + t3code = wrapT3 prev.llm-agents.t3code; + t3code-desktop = wrapT3 prev.llm-agents.t3code-desktop; + }; + }; + # temp-packages = final: _prev: { # temp = import inputs.nixpkgs-9e9486b { # system = final.stdenv.hostPlatform.system;