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
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user