From 29e7cf185ef8fba1b299d71b7ebff07fa3ca4ed8 Mon Sep 17 00:00:00 2001 From: weichen Date: Thu, 15 Oct 2026 08:59:17 +0000 Subject: [PATCH] Make transport commits independent of Git identity Why: PR #567 CI runs without a global Git user identity, causing every successful agent transport commit to fail with exit 128. Evidence: The focused no-identity regression plus AgentExecControllerTests and AgentExecHistoryTests pass (30 executions total); git diff --check passes. Impact: Supplies a deterministic non-secret identity only to git commit-tree; routing, receipts, and transport validation are unchanged. Refs: #567 --- scripts/agent_exec.py | 8 ++++++++ tests/test_agent_exec.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/scripts/agent_exec.py b/scripts/agent_exec.py index 3747f9a8..be71f6b3 100644 --- a/scripts/agent_exec.py +++ b/scripts/agent_exec.py @@ -47,6 +47,10 @@ EXIT_SCOPE_EXPANSION = 5 EXIT_CANCELLED = 6 EXIT_HOST_FALLBACK = 10 +# Transport commits must not depend on machine-global Git identity. +TRANSPORT_AUTHOR_NAME = "agent-exec-transport" +TRANSPORT_AUTHOR_EMAIL = "agent-exec-transport@localhost.invalid" + DEFAULT_BRANCHES = frozenset({"main", "master"}) SECRET_PATH_MARKERS = ( ".secrets", @@ -1627,6 +1631,10 @@ def _create_transport_commit( msg = f"agent-exec transport {run_id}/{attempt_id}" commit = _git( worktree, + "-c", + f"user.name={TRANSPORT_AUTHOR_NAME}", + "-c", + f"user.email={TRANSPORT_AUTHOR_EMAIL}", "commit-tree", tree, "-p", diff --git a/tests/test_agent_exec.py b/tests/test_agent_exec.py index db745136..1b0fe01c 100644 --- a/tests/test_agent_exec.py +++ b/tests/test_agent_exec.py @@ -1685,6 +1685,38 @@ class AgentExecControllerTests(unittest.TestCase): self.assertEqual(launched.read_text(encoding="utf-8"), "") self._assert_canonical_untouched() + def test_transport_commit_does_not_require_configured_git_identity(self) -> None: + base_head = _git(self.repo, "rev-parse", "HEAD").stdout.strip() + _git(self.repo, "config", "--unset-all", "user.name") + _git(self.repo, "config", "--unset-all", "user.email") + worktree = self.root / "no-identity-worktree" + agent_exec._create_private_attempt_clone(self.repo, worktree, base_head) + (worktree / "src" / "marker.txt").write_text("ok\n", encoding="utf-8") + + clean_git_env = { + "PATH": os.environ["PATH"], + "GIT_CONFIG_GLOBAL": "/dev/null", + "GIT_CONFIG_NOSYSTEM": "1", + } + with mock.patch.dict(os.environ, clean_git_env, clear=True): + ref = agent_exec._create_transport_commit( + repo=self.repo, + worktree=worktree, + base_head=base_head, + run_id="no-identity", + attempt_id="attempt-1", + inventory={"paths": ["src/marker.txt"]}, + ) + + identity = _git( + self.repo, "log", "-1", "--format=%an <%ae>|%cn <%ce>", ref + ).stdout.strip() + expected = ( + f"{agent_exec.TRANSPORT_AUTHOR_NAME} " + f"<{agent_exec.TRANSPORT_AUTHOR_EMAIL}>" + ) + self.assertEqual(identity, f"{expected}|{expected}") + class AgentExecHistoryTests(unittest.TestCase): def setUp(self) -> None: